Class: Exo::ItemPresenter
- Inherits:
-
Object
- Object
- Exo::ItemPresenter
- Defined in:
- app/presenters/exo/item_presenter.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(item, decorated_resource = nil) ⇒ ItemPresenter
constructor
A new instance of ItemPresenter.
- #method_missing(meth, *params, &block) ⇒ Object
Constructor Details
#initialize(item, decorated_resource = nil) ⇒ ItemPresenter
Returns a new instance of ItemPresenter.
5 6 7 8 |
# File 'app/presenters/exo/item_presenter.rb', line 5 def initialize item, decorated_resource=nil self.item = item self.resource = decorated_resource || ResourcePresenter.new(item.resource) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *params, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/presenters/exo/item_presenter.rb', line 10 def method_missing meth, *params, &block _field = resource.(meth) if _field item.value_for _field else item.send meth, *params, &block end end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
3 4 5 |
# File 'app/presenters/exo/item_presenter.rb', line 3 def item @item end |
#resource ⇒ Object
Returns the value of attribute resource.
3 4 5 |
# File 'app/presenters/exo/item_presenter.rb', line 3 def resource @resource end |