Class: Houston::Roadmaps::RoadmapPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/houston/roadmaps/roadmap_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(roadmaps) ⇒ RoadmapPresenter

Returns a new instance of RoadmapPresenter.



3
4
5
# File 'app/presenters/houston/roadmaps/roadmap_presenter.rb', line 3

def initialize(roadmaps)
  @roadmaps = OneOrMany.new(roadmaps)
end

Instance Method Details

#as_json(*args) ⇒ Object



7
8
9
# File 'app/presenters/houston/roadmaps/roadmap_presenter.rb', line 7

def as_json(*args)
  @roadmaps.map(&method(:to_hash))
end

#to_hash(roadmap) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/presenters/houston/roadmaps/roadmap_presenter.rb', line 11

def to_hash(roadmap)
  { id: roadmap.id,
    name: roadmap.name,
    projects: roadmap.projects.map { |project| {
      id: project.id,
      name: project.name,
      color: project.color } },
    milestones: present_milestones(roadmap.milestones) }
end