Class: Chemlab::Resource::DSL
- Inherits:
-
Object
- Object
- Chemlab::Resource::DSL
- Defined in:
- lib/chemlab/resource.rb
Instance Method Summary collapse
- #attribute(name, &block) ⇒ Object
-
#initialize(base) ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize(base) ⇒ DSL
Returns a new instance of DSL.
149 150 151 |
# File 'lib/chemlab/resource.rb', line 149 def initialize(base) @base = base end |
Instance Method Details
#attribute(name, &block) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/chemlab/resource.rb', line 153 def attribute(name, &block) @base.module_eval do attr_writer(name) define_method(name) do instance_variable_get("@#{name}") || instance_variable_set( "@#{name}", populate_attribute(name, block)) end end end |