Class: Houston::Roadmaps::MilestoneApiPresenter
- Inherits:
-
Object
- Object
- Houston::Roadmaps::MilestoneApiPresenter
- Defined in:
- app/presenters/houston/roadmaps/milestone_api_presenter.rb
Instance Method Summary collapse
- #as_json(*args) ⇒ Object
-
#initialize(milestones) ⇒ MilestoneApiPresenter
constructor
A new instance of MilestoneApiPresenter.
- #to_hash(milestone) ⇒ Object
Constructor Details
#initialize(milestones) ⇒ MilestoneApiPresenter
Returns a new instance of MilestoneApiPresenter.
3 4 5 |
# File 'app/presenters/houston/roadmaps/milestone_api_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/milestone_api_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/milestone_api_presenter.rb', line 11 def to_hash(milestone) project = milestone.project { id: milestone.id, name: milestone.name, projectId: project.id, projectName: project.name, projectSlug: project.slug, tickets: milestone.tickets.map { |ticket| { id: ticket.id, number: ticket.number, summary: ticket.summary } }, startDate: milestone.start_date, endDate: milestone.end_date } end |