Module: Convection::DSL::ClassHelpers
- Defined in:
- lib/convection/dsl/helpers.rb
Overview
Methods for defining DSL/Models
Instance Method Summary collapse
Instance Method Details
#attribute(attribute_name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/convection/dsl/helpers.rb', line 10 def attribute(attribute_name) attr_writer attribute_name define_method(attribute_name) do |value = nil| instance_variable_set("@#{ attribute_name }", value) unless value.nil? instance_variable_get("@#{ attribute_name }") end end |
#list(attribute_name) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/convection/dsl/helpers.rb', line 18 def list(attribute_name) define_method(attribute_name) do |value = nil| collection = instance_variable_get("@#{ attribute_name }") collection << value unless value.nil? collection end end |