Module: Eazypi::SpecObject::ClassMethods
- Defined in:
- lib/eazypi/spec_object.rb
Overview
ClassMethods for SpecObject
Instance Method Summary collapse
Instance Method Details
#spec_attribute(attribute_name, spec_type = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eazypi/spec_object.rb', line 24 def spec_attribute(attribute_name, spec_type = nil) define_method(attribute_name) do |v = nil, &block| if spec_type && block v = spec_type.new v.load(&block) end instance_variable_set(:"@#{attribute_name}", v) if v instance_variable_get(:"@#{attribute_name}") end end |