Sha256: 7db1319f10b4224e2f2e87c91883b551c60d8cae2863b3bb872cd72884d2bff6

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

# lib/stair_master/concerns/traverser.rb
##
##
##
module StairMaster
  module Concerns
    module Traversal
      extend ActiveSupport::Concern

      included do
        helper_method :current_step,
                      :current_step_name,
                      :current_step_index,
                      :next_step,
                      :next_step_index,
                      :next_step_name,
                      :previous_step,
                      :previous_step_index,
                      :previous_step_name
      end

      ## Current Step -------------------------------------
      def current_step_index
        @stair_master_current_step_index ||= get_step_index_by_name current_step_name
      end

      def current_step
        @stair_master_current_step ||= get_step_by_index current_step_index
      end

      def current_step_name
        @stair_master_current_step_name ||= controller_name.to_sym
      end

      ## Next Step ----------------------------------------
      def next_step_index
        @stair_master_next_step_index ||= get_next_step_index
      end

      def next_step
        @stair_master_next_step ||= ( next_step_index.nil? ? nil : get_step_by_index(next_step_index) )
      end

      def next_step_name
        @stair_master_next_step_name ||= ( next_step_index.nil? ? nil : get_step_name_by_index(next_step_index) )
      end

      ## Previous Step ------------------------------------
      def previous_step_index(base_step_index=nil)
        @stair_master_previous_step_index ||= get_previous_step_index
      end

      def previous_step
        @stair_master_previous_step ||= ( previous_step_index.nil? ? nil : get_step_by_index(previous_step_index) )
      end

      def previous_step_name
        @stair_master_previous_step_name ||= ( previous_step_index.nil? ? nil : get_step_name_by_index(previous_step_index) )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stair_master-0.0.1 lib/stair_master/concerns/traversal.rb