Method: Intermodal::Mapping::Presenter.call

Defined in:
lib/intermodal/mapping/presenter.rb

.call(resource, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/intermodal/mapping/presenter.rb', line 23

def call(resource, options = {})
  _scope = options[:scope] || :default

  if options[:root] || options[:always_nest_collections]
    { (options[:root].is_a?(TrueClass) || options[:root].nil? ? model_name(resource) : options[:root]) => map_attributes(resource, _scope) }
  else
    map_attributes(resource, _scope)
  end
end