Class: ReleasePresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(releases) ⇒ ReleasePresenter

Returns a new instance of ReleasePresenter.



3
4
5
# File 'app/presenters/release_presenter.rb', line 3

def initialize(releases)
  @releases = releases
end

Instance Method Details

#as_json(*args) ⇒ Object



7
8
9
10
11
12
13
# File 'app/presenters/release_presenter.rb', line 7

def as_json(*args)
  if @releases.is_a?(Release)
    to_hash @releases
  else
    @releases.map(&method(:to_hash))
  end
end

#to_hash(release) ⇒ Object



15
16
17
18
# File 'app/presenters/release_presenter.rb', line 15

def to_hash(release)
  { id: release.id,
    createdAt: release.created_at }
end