Module: GenericViewMapper::SchemaDefinition::DSL
- Included in:
- GenericViewMapper::Section
- Defined in:
- lib/generic_view_mapper/view/schema_definition.rb
Instance Method Summary collapse
- #attribute(name, options = {}) ⇒ Object
- #attributes ⇒ Object
- #attributes=(value) ⇒ Object
- #section(name, &block) ⇒ Object
Instance Method Details
#attribute(name, options = {}) ⇒ Object
16 17 18 |
# File 'lib/generic_view_mapper/view/schema_definition.rb', line 16 def attribute(name, = {}) attributes << Attribute.new(name, ) end |
#attributes ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/generic_view_mapper/view/schema_definition.rb', line 4 def attributes @attributes ||= if is_a?(Class) && superclass.respond_to?(:attributes) superclass.attributes.clone else [] end end |
#attributes=(value) ⇒ Object
12 13 14 |
# File 'lib/generic_view_mapper/view/schema_definition.rb', line 12 def attributes=(value) @attributes = value end |
#section(name, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/generic_view_mapper/view/schema_definition.rb', line 20 def section(name, &block) section = Section.new(name) if (old_section = attributes.find { |x| x.name == name }) attributes.delete(old_section) section.attributes += old_section.attributes end section.instance_eval(&block) attributes << section end |