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 # => 26You can even pass in a block.
(Source: rubydoc.info)
19 notes (via rubyquicktips & rubyflare)
Nice one, didn’t know this and it’s totally useful. rubyquicktips: