Module: InstanceEvalAttr
- Included in:
- FarmingEngineers::Invoices::Common::Invoice
- Defined in:
- lib/instance_eval_attr.rb
Instance Method Summary collapse
Instance Method Details
#instance_eval_attr(*names) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/instance_eval_attr.rb', line 2 def instance_eval_attr(*names) names.each do |name| varname= "@#{name}" define_method name do |*args| instance_variable_set(varname, args.first) unless args.empty? instance_variable_get(varname) end define_method "#{name}=" do |val| instance_variable_set(varname, val) end end end |