Module: Chemlab::Attributable
- Defined in:
- lib/chemlab/attributable.rb
Overview
Attributable module
Instance Method Summary collapse
Instance Method Details
#attribute(name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chemlab/attributable.rb', line 12 def attribute(name) default_value = nil default_value = yield if block_given? define_method(name) do instance_variable_get("@#{name}") || instance_variable_set( "@#{name}", default_value ) end end |