Class: LastThreeCommentsDecorator

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

Instance Method Summary collapse

Constructor Details

#initialize(presenter) ⇒ LastThreeCommentsDecorator

Returns a new instance of LastThreeCommentsDecorator.


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

def initialize(presenter)
  @presenter = presenter
end

Instance Method Details

#as_json(options = {}) ⇒ Object


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

def as_json(options={})
  @presenter.as_json.tap do |post|
    post[:interactions].merge!(:comments => CommentPresenter.as_collection(@presenter.post.last_three_comments))
  end
end