Module: Smooth::Presentable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/smooth/presentable.rb,
lib/smooth/presentable/chain.rb,
lib/smooth/presentable/controller.rb,
lib/smooth/presentable/api_endpoint.rb
Defined Under Namespace
Modules: ClassMethods, Controller Classes: ApiEndpoint, AttributeDelegator, Chain
Instance Method Summary collapse
Instance Method Details
#present_as(format = :default) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/smooth/presentable.rb', line 16 def present_as(format=:default) record = self keys = self.class.presenter_class && self.class.presenter_class.respond_to?(format) && self.class.presenter_class.send(format) keys ||= self.class.default_presenter_attributes Array(keys).inject({}) do |memo,item| AttributeDelegator.pluck(record, item, memo) end end |