Module: GoodData::Mixin::PropertyAccessor

Included in:
ContextManager
Defined in:
lib/gooddata/mixins/property_accessor.rb

Instance Method Summary collapse

Instance Method Details

#property_accessor(*args) ⇒ Object



24
25
26
27
# File 'lib/gooddata/mixins/property_accessor.rb', line 24

def property_accessor(*args)
  property_reader(*args)
  property_writer(*args)
end

#property_reader(where, *props) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/gooddata/mixins/property_accessor.rb', line 8

def property_reader(where, *props)
  props.each do |prop|
    define_method(prop, proc {
      instance_variable_get(where)[prop]
    })
  end
end

#property_writer(where, *props) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/gooddata/mixins/property_accessor.rb', line 16

def property_writer(where, *props)
  props.each do |prop|
    define_method("#{prop}=", proc { |val|
      instance_variable_get(where)[prop] = val
    })
  end
end