Class: Exo::ResourcePresenter
- Inherits:
-
Object
- Object
- Exo::ResourcePresenter
- Defined in:
- app/presenters/exo/resource_presenter.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource) ⇒ ResourcePresenter
constructor
A new instance of ResourcePresenter.
- #item(slug_id) ⇒ Object
- #items ⇒ Object
- #meta_field(name) ⇒ Object
- #wrap_item(i) ⇒ Object
Constructor Details
#initialize(resource) ⇒ ResourcePresenter
Returns a new instance of ResourcePresenter.
5 6 7 |
# File 'app/presenters/exo/resource_presenter.rb', line 5 def initialize resource self.resource = resource end |
Instance Attribute Details
#resource ⇒ Object
Returns the value of attribute resource.
3 4 5 |
# File 'app/presenters/exo/resource_presenter.rb', line 3 def resource @resource end |
Instance Method Details
#item(slug_id) ⇒ Object
13 14 15 |
# File 'app/presenters/exo/resource_presenter.rb', line 13 def item slug_id ItemPresenter.new items.find_by(slug_id: slug_id), self end |
#items ⇒ Object
9 10 11 |
# File 'app/presenters/exo/resource_presenter.rb', line 9 def items ScopeWraper.new resource.items, self end |
#meta_field(name) ⇒ Object
17 18 19 |
# File 'app/presenters/exo/resource_presenter.rb', line 17 def name resource..where(slug_id: name.to_s).first end |
#wrap_item(i) ⇒ Object
21 22 23 |
# File 'app/presenters/exo/resource_presenter.rb', line 21 def wrap_item i ItemPresenter.new i, self end |