Class: Intermodal::Mapping::Presenter
- Defined in:
- lib/intermodal/mapping/presenter.rb
Constant Summary
Constants inherited from Mapper
Mapper::EXCLUDE_NILS, Mapper::INCLUDE_NILS
Class Method Summary collapse
Methods inherited from Mapper
exclude_properties, map_attribute, map_attributes, maps, presenters, property_mapping
Methods included from DSL::PresentationHelpers
#attribute, #helper, #map_to, #maybe, #params, #presenter, #to_datetime, #to_presentation
Class Method Details
.call(resource, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/intermodal/mapping/presenter.rb', line 23 def call(resource, = {}) _scope = [:scope] || :default if [:root] || [:always_nest_collections] { ([:root].is_a?(TrueClass) || [:root].nil? ? model_name(resource) : [:root]) => map_attributes(resource, _scope) } else map_attributes(resource, _scope) end end |
.model_name(resource) ⇒ Object
19 20 21 |
# File 'lib/intermodal/mapping/presenter.rb', line 19 def model_name(resource) resource.class.name.demodulize.underscore end |