Sha256: 3cf7aaac77852ea19e75dc91a909f66faeefd7296d2a44538302b9c53d5975c3

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

# lib/stair_master/concerns/tests.rb
##
##
##
module StairMaster
  module Concerns
    module Tests
      extend ActiveSupport::Concern

      included do
        helper_method :on_first_step?,
                      :on_last_step?
      end

      ## Methods ------------------------------------------
      def on_last_step?
        @stair_master_on_last_step ||= is_last_step?(current_step_name)
      end

      def on_first_step?
        @stair_master_on_first_step ||= is_first_step?(current_step_name)
      end

      def is_last_step?(step_name)
        step_name == available_steps.last
      end

      def is_first_step?(step_name)
        step_name == available_steps.first
      end

      def is_available_step?(step=nil)
        step_name = step.nil? ? controller_name.to_sym : step.key
        available_steps.include? step_name
      end

      def step_should_be_skipped?(step=nil)
        step = step.nil? ? current_step : step
        step.skip?(self)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stair_master-0.0.3 lib/stair_master/concerns/tests.rb
stair_master-0.0.2 lib/stair_master/concerns/tests.rb