Here’s a method I haven’t seen before: attr_accessor_with_default
This ActiveSupport method allows you to set a default value for an attribute accessor:
class Person attr_accessor_with_default :age, 25 end some_person.age # => 25 some_person.age = 26 some_person.age # => 26
You can even pass in a block.
19 notes 0 comments (via rubyflare)
Nice one, didn’t know this and it’s totally useful.
Here’s a method I haven’t seen before: attr_accessor_with_default This ActiveSupport method allows you to set a default...
You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.