I hereby claim:
- I am tomdalling on github.
- I am tomdalling (https://keybase.io/tomdalling) on keybase.
- I have a public key ASDAMWx4M_UpLqjxz-ZUxQCZoDl8Tt18bKoclREuxqQo2go
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| require 'json' | |
| COLORS = { | |
| '#' => '#216e39', | |
| '+' => '#30a14e', | |
| ':' => '#40c463', | |
| '-' => '#9be9a8', | |
| '.' => '#ebedf0', | |
| ' ' => nil, | |
| } |
| Mutant environment: | |
| Matcher: #<Mutant::Matcher::Config match_expressions: [C]> | |
| Integration: rspec | |
| Jobs: 8 | |
| Includes: [] | |
| Requires: ["./c"] | |
| Subjects: 1 | |
| Total-Tests: 90 | |
| Selected-Tests: 1 | |
| Tests/Subject: 1.00 avg |
| Running test/automated/zettel/hashtag_query.rb | |
| Zettel::HashtagQuery | |
| matches the presence of a hashtag | |
| with syntax: #a | |
| provides logical NOT | |
| with syntax: NOT #a | |
| with syntax: not #a | |
| with syntax: !#a | |
| provides logical AND | |
| with syntax: #a AND #b |
| # Schema: entries[ id, account_id, creator_id, created_at, updated_at, specialization_type, specialization_id ] | |
| class Entry < ApplicationRecord | |
| has_specialization types: %w[ Message Comment ] | |
| belongs_to :account | |
| belongs_to :creator | |
| end | |
| # Schema: messages[ id, subject ] | |
| class Message < ApplicationRecord | |
| is_specialization_of 'Entry' |
When I do puts method_name inside #respond_to_missing?, it outputs begin,
so it looks like it's treating self as if it were a Range.
This is the RSpec output:
An error occurred while loading ./spec/value_semantics_spec.rb.
Failure/Error: first_letter = method_name[self]
SystemStackError:
stack level too deep
| title | layout | date | snippet_source |
|---|---|---|---|
Super Secret Methods |
post |
2017-07-16 |
code/super_secret_methods.rb |
Here is a quirk of the Ruby language that I discovered a few weeks ago.
Method names can not contain a period character.
I like the idea of providing an RSpec shared example to test all these behaviours.
For the constructor, I would change "consider using keywords" to "should use keywords". Keywords should be the default, unless the order is really obvious.
Re: "Value construction options could be provided by keyword arguments." I would probably prefer value contruction options to be in separate class methods, instead of #new.
Re: caching. I would be hesitant to do this at the global level (e.g. stored in the class).
| class CommentsController | |
| def create | |
| result = CreateComment.call(params, @user) | |
| if result.ok? | |
| render :partial => "comments/postedreply", :layout => false, | |
| :content_type => "text/html", :locals => { :comment => result.value } | |
| else | |
| case result.error.name | |
| when :story_not_found | |
| render :plain => "can't find story", :status => 400 |