Class: Exo::ResourcePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/exo/resource_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#resourceObject

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

#itemsObject



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 meta_field name
  resource.meta_fields.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