Method: Class#blockable_attr_accessor

Defined in:
lib/support/class_options.rb

#blockable_attr_accessor(sym) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/support/class_options.rb', line 9

def blockable_attr_accessor(sym)
  module_eval(<<-EVAL, __FILE__, __LINE__)
    def #{sym}(&block)
      if block_given?
        @#{sym} = block
      else
        @#{sym}
      end
    end
    def #{sym}=(value)
      @#{sym} = value
    end
  EVAL
end