Sha256: 74f7d52da2d9f0f3af61e5a91b7e599d740711a1114e4d14da027708b8d36fa4

Contents?: true

Size: 896 Bytes

Versions: 7

Compression:

Stored size: 896 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, &block)
            if block_given?
              step_without_blockless(value, &block)
            else
              returning [] do |array|
                step_without_blockless(value) { |step| array << step }
              end
            end
          end
        else
          def step_with_blockless(value, &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

7 entries across 7 versions & 3 rubygems

Version Path
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.1.0 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.0.5 lib/active_support/core_ext/range/blockless_step.rb
activesupport-2.0.4 lib/active_support/core_ext/range/blockless_step.rb
antfarm-0.3.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb
antfarm-0.4.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb