Method: Middlewares::Decorator::Representable.decorate

Defined in:
lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/middlewares/decorator/representable.rb

.decorate(object, options) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/middlewares/decorator/representable.rb', line 13

def self.decorate(object, options)
  decorator = "::Decorators::#{options[:decorator].to_s.camelize}".constantize

  if options[:collection?]
    decorator.for_collection.new(object.to_a).to_hash
  else
    decorator.new(object).to_hash
  end
end