class Cyrax::Presenter
Public Class Methods
present(resource, options = {})
click to toggle source
# File lib/cyrax/presenter.rb, line 12 def present(resource, options = {}) self.new(resource, options).present end
Public Instance Methods
present()
click to toggle source
# File lib/cyrax/presenter.rb, line 2 def present should_decorate = options[:decorate].nil? || options[:decorate] if options[:decorator] && should_decorate present_with_decoration(resource, options) else present_without_decoration(resource, options) end end
Private Instance Methods
present_with_decoration(resource, options)
click to toggle source
# File lib/cyrax/presenter.rb, line 19 def present_with_decoration(resource, options) if options[:present] == :collection Cyrax::Presenters::DecoratedCollection.new(resource, options) else options[:decorator].decorate(resource, options) end end
present_without_decoration(resource, options)
click to toggle source
# File lib/cyrax/presenter.rb, line 27 def present_without_decoration(resource, options) if options[:present] == :collection Cyrax::Presenters::BaseCollection.new(resource, options) else resource end end