Module: AbstractMapper::Attributes::DSL
- Defined in:
- lib/abstract_mapper/attributes.rb
Overview
Attributes DSL
Instance Method Summary collapse
-
#attribute(name, options = {}) ⇒ undefined
Declares the attribute.
-
#attributes ⇒ Hash
Default attributes for the node.
-
#inherited(klass) ⇒ Object
Makes a attributes inheritable.
Instance Method Details
#attribute(name, options = {}) ⇒ undefined
Declares the attribute
56 57 58 59 |
# File 'lib/abstract_mapper/attributes.rb', line 56 def attribute(name, = {}) attributes[name.to_sym] = [:default] define_method(name) { attributes[name.to_sym] } end |
#attributes ⇒ Hash
Default attributes for the node
44 45 46 |
# File 'lib/abstract_mapper/attributes.rb', line 44 def attributes @attributes ||= {} end |
#inherited(klass) ⇒ Object
Makes a attributes inheritable
36 37 38 |
# File 'lib/abstract_mapper/attributes.rb', line 36 def inherited(klass) attributes.each { |key, value| klass.attribute key, default: value } end |