Class: Houston::Roadmaps::RoadmapMilestonePresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(milestones) ⇒ RoadmapMilestonePresenter

Returns a new instance of RoadmapMilestonePresenter.



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

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

Instance Method Details

#as_json(*args) ⇒ Object



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

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

#to_hash(milestone) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/presenters/houston/roadmaps/roadmap_milestone_presenter.rb', line 11

def to_hash(milestone)
  project = milestone.project
  { id: milestone.id,
    name: milestone.name,
    milestoneId: milestone.milestone_id,
    projectId: project.id,
    projectColor: project.color,
    percentComplete: percent_complete(milestone),
    completed: milestone.completed?,
    band: milestone.band,
    lanes: milestone.lanes,
    startDate: milestone.start_date,
    endDate: milestone.end_date,
    removed: milestone.destroyed_at.present? }
end