# lib/stair_master/concerns/getters.rb ## ## ## module StairMaster module Concerns module Getters extend ActiveSupport::Concern def get_step_index_by_name(step_name) available_steps.find_index step_name end def get_step_name_by_index(step_index) available_steps[step_index] end def get_step_by_index(step_index) get_step_by_name available_steps[step_index] end def get_step_by_name(step_name) workflow_map.steps[step_name] end def get_next_step_index on_last_step? ? nil : find_next_step_index end def get_previous_step_index(step_index=nil) on_first_step? ? nil : find_previous_step_index end private # ------------------------------------------- def find_previous_step_index(step_index=nil) previous_index = step_index.nil? ? current_step_index.pred : step_index.pred step = get_step_by_index previous_index if step.nil? nil elsif step.skip?(self) find_previous_step_index(previous_index) else previous_index end end def find_next_step_index(step_index=nil) next_index = step_index.nil? ? current_step_index.next : step_index.next step = get_step_by_index next_index if step.nil? nil elsif step.skip?(self) find_next_step_index(next_index) else next_index end end end end end