Class: GenericViewMapper::Section
- Inherits:
-
Object
- Object
- GenericViewMapper::Section
- Defined in:
- lib/generic_view_mapper/view/section.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #field_name ⇒ Object
-
#initialize(name) ⇒ Section
constructor
A new instance of Section.
- #render(target, view_context) ⇒ Object
Methods included from Import::DSL
#from_json, #from_yaml, #import, #json, #yaml
Methods included from GenericViewMapper::SchemaDefinition::DSL
#attribute, #attributes, #attributes=, #section
Constructor Details
#initialize(name) ⇒ Section
Returns a new instance of Section.
8 9 10 |
# File 'lib/generic_view_mapper/view/section.rb', line 8 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/generic_view_mapper/view/section.rb', line 6 def name @name end |
Instance Method Details
#field_name ⇒ Object
12 13 14 15 16 17 |
# File 'lib/generic_view_mapper/view/section.rb', line 12 def field_name name .to_s .camelize(:lower) .to_sym end |
#render(target, view_context) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/generic_view_mapper/view/section.rb', line 19 def render(target, view_context) { field_name => attributes.inject({}) do |accum, el| accum.merge(el.render(target, view_context)) end } end |