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


2
3
4
# File 'app/presenters/last_three_comments_decorator.rb', line 2

def initialize(presenter)
  @presenter = presenter
end

Instance Method Details

#as_json(options = {}) ⇒ Object


6
7
8
9
10
# File 'app/presenters/last_three_comments_decorator.rb', line 6

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