Class: Houston::Roadmaps::RoadmapPresenter
- Inherits:
-
Object
- Object
- Houston::Roadmaps::RoadmapPresenter
- Defined in:
- app/presenters/houston/roadmaps/roadmap_presenter.rb
Instance Method Summary collapse
- #as_json(*args) ⇒ Object
-
#initialize(roadmaps) ⇒ RoadmapPresenter
constructor
A new instance of RoadmapPresenter.
- #to_hash(roadmap) ⇒ Object
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 |