Class: MetadataPresenter::TraversedPages

Inherits:
Object
  • Object
show all
Defined in:
app/models/metadata_presenter/traversed_pages.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, user_data, current_page = nil) ⇒ TraversedPages

Returns a new instance of TraversedPages.



5
6
7
8
9
10
# File 'app/models/metadata_presenter/traversed_pages.rb', line 5

def initialize(service, user_data, current_page = nil)
  @service = service
  @user_data = user_data
  @pages = [service.start_page]
  @current_page = current_page
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



3
4
5
# File 'app/models/metadata_presenter/traversed_pages.rb', line 3

def current_page
  @current_page
end

#serviceObject (readonly)

Returns the value of attribute service.



3
4
5
# File 'app/models/metadata_presenter/traversed_pages.rb', line 3

def service
  @service
end

#user_dataObject (readonly)

Returns the value of attribute user_data.



3
4
5
# File 'app/models/metadata_presenter/traversed_pages.rb', line 3

def user_data
  @user_data
end

Instance Method Details

#allObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/metadata_presenter/traversed_pages.rb', line 14

def all
  next_object = service.start_page

  service.flow.size.times do
    break if next_object.blank? || next_object.uuid == current_page&.uuid

    flow_object = service.flow_object(next_object.uuid)
    next_object = flow_object.branch? ? evaluated_page(flow_object) : next_flow_object(flow_object.default_next)
    @pages.push(next_object) if page_in_flow?(next_object)
  end

  @pages
end