Module: FunkyAccessor
- Defined in:
- lib/funky_accessor.rb,
lib/funky_accessor/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/funky_accessor.rb', line 2 def self.extended base class << base def funky_accessor *names names.each do |name| define_method(name) do |arg=nil, &block| if block instance_variable_set(:"@#{name}", block.call) elsif arg instance_variable_set(:"@#{name}", arg) else instance_variable_get(:"@#{name}") end end end end end end |