Method: Module#cattr_accessor
- Defined in:
- lib/core/facets/module/mattr.rb
#cattr_accessor(*syms) ⇒ Object
Creates a class-variable attr_accessor that can be accessed both on an instance and class level.
class CAAExample
cattr_accessor :a
end
CAAExample.a = 10
CAAExample.a #=> 10
mc = CAAExample.new
mc.a #=> 10
NOTE: This method is not a common core extension and is not loaded automatically when using require 'facets'.
CREDIT: David Heinemeier Hansson
133 134 135 |
# File 'lib/core/facets/module/mattr.rb', line 133 def cattr_accessor(*syms) cattr_reader(*syms) + cattr_writer(*syms) end |