Sha256: 5b684eca1a1d1115a4ddbb41bd55a39197259ab6bf73bccc84f3b16274f4910b

Contents?: true

Size: 898 Bytes

Versions: 15

Compression:

Stored size: 898 Bytes

Contents

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module Range #:nodoc:
      # Return an array when step is called without a block.
      module BlocklessStep
        def self.included(base) #:nodoc:
          base.alias_method_chain :step, :blockless
        end

        if RUBY_VERSION < '1.9'
          def step_with_blockless(value = 1, &block)
            if block_given?
              step_without_blockless(value, &block)
            else
              [].tap do |array|
                step_without_blockless(value) { |step| array << step }
              end
            end
          end
        else
          def step_with_blockless(value = 1, &block)
            if block_given?
              step_without_blockless(value, &block)
            else
              step_without_blockless(value).to_a
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
activesupport-2.3.18 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.17 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.16 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.15 lib/active_support/core_ext/range/blockless_step.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/activesupport-2.3.14/lib/active_support/core_ext/range/blockless_step.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/activesupport-2.3.12/lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.14 lib/active_support/core_ext/range/blockless_step.rb
kajam-1.0.3.rc2 vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.12 lib/active_support/core_ext/range/blockless_step.rb
radiant-1.0.0.rc2 vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
radiant-1.0.0.rc1 vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.11 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.10 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.9 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.3.9.pre lib/active_support/core_ext/range/blockless_step.rb