Module: RailsSimpleExposure
- Defined in:
- lib/rails_simple_exposure.rb,
lib/rails_simple_exposure/version.rb
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Method Summary collapse
Instance Method Details
#expose(name, value) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails_simple_exposure.rb', line 2 def expose(name, value) instance_variable_name = "@#{name}" define_method name do return instance_variable_get instance_variable_name if instance_variable_defined? instance_variable_name instance_variable_set instance_variable_name, instance_eval(&value) end define_method :"#{name}=" do |value| instance_variable_set instance_variable_name, value end private :"#{name}=" helper_method name end |