Class: AspectPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/aspect_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_user

Instance Method Summary collapse

Methods inherited from BasePresenter

as_collection, #method_missing, new

Constructor Details

#initialize(aspect) ⇒ AspectPresenter

Returns a new instance of AspectPresenter.


4
5
6
# File 'app/presenters/aspect_presenter.rb', line 4

def initialize(aspect)
  @aspect = aspect
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BasePresenter

Instance Method Details

#as_api_json(full = false, with_order: true) ⇒ Object


14
15
16
17
18
19
20
21
# File 'app/presenters/aspect_presenter.rb', line 14

def as_api_json(full=false, with_order: true)
  values = {
    id:   @aspect.id,
    name: @aspect.name
  }
  values[:order] = @aspect.order_id if with_order
  values
end

#as_jsonObject


8
9
10
11
12
# File 'app/presenters/aspect_presenter.rb', line 8

def as_json
  { :id => @aspect.id,
    :name => @aspect.name,
  }
end

#to_json(options = {}) ⇒ Object


23
24
25
# File 'app/presenters/aspect_presenter.rb', line 23

def to_json(options={})
  as_json.to_json(options)
end