diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-09 07:49:16 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-09 07:49:16 +0000 |
commit | d556f466079d329ee678afe0c11db914894cb4b0 (patch) | |
tree | 017ab4fae052db18c5a90364a8aeb6dfb4975b87 /activesupport/lib | |
parent | fba05826dc0433e177e8cf72b9ef12878fd97586 (diff) | |
download | rails-d556f466079d329ee678afe0c11db914894cb4b0.tar.gz rails-d556f466079d329ee678afe0c11db914894cb4b0.tar.bz2 rails-d556f466079d329ee678afe0c11db914894cb4b0.zip |
Style update for new Range extensions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7818 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
4 files changed, 19 insertions, 26 deletions
diff --git a/activesupport/lib/active_support/core_ext/range.rb b/activesupport/lib/active_support/core_ext/range.rb index c3ef624617..0d2b169e3f 100644 --- a/activesupport/lib/active_support/core_ext/range.rb +++ b/activesupport/lib/active_support/core_ext/range.rb @@ -1,7 +1,7 @@ require 'active_support/core_ext/range/conversions' -require File.dirname(__FILE__) + '/range/overlaps' -require File.dirname(__FILE__) + '/range/include_range' -require File.dirname(__FILE__) + '/range/blockless_step' +require 'active_support/core_ext/range/overlaps' +require 'active_support/core_ext/range/include_range' +require 'active_support/core_ext/range/blockless_step' class Range #:nodoc: include ActiveSupport::CoreExtensions::Range::Conversions diff --git a/activesupport/lib/active_support/core_ext/range/blockless_step.rb b/activesupport/lib/active_support/core_ext/range/blockless_step.rb index 4d5e27457b..bc69263abb 100644 --- a/activesupport/lib/active_support/core_ext/range/blockless_step.rb +++ b/activesupport/lib/active_support/core_ext/range/blockless_step.rb @@ -1,25 +1,22 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Range #:nodoc: - # Return and array when step is called without a block + # Return an array when step is called without a block. module BlocklessStep + def self.included(base) #:nodoc: + base.alias_method_chain :step, :blockless + end - def self.included(klass) #:nodoc: - klass.send(:alias_method, :step_with_block, :step) - klass.send(:alias_method, :step, :step_without_block) - end - - def step_without_block(value, &block) + def step_with_blockless(value, &block) if block_given? - step_with_block(value, &block) + step_without_blockless(value, &block) else returning [] do |array| - step_with_block(value) {|step| array << step } + step_without_blockless(value) { |step| array << step } end end end - end end end -end
\ No newline at end of file +end diff --git a/activesupport/lib/active_support/core_ext/range/include_range.rb b/activesupport/lib/active_support/core_ext/range/include_range.rb index a6b4e9ff64..cd53cf154a 100644 --- a/activesupport/lib/active_support/core_ext/range/include_range.rb +++ b/activesupport/lib/active_support/core_ext/range/include_range.rb @@ -1,13 +1,12 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Range #:nodoc: - # Check if a Range includes another Range + # Check if a Range includes another Range. module IncludeRange + def self.included(base) #:nodoc: + base.alias_method_chain :include?, :range + end - def self.included(klass) #:nodoc: - klass.send(:alias_method_chain, :include?, :range) - end - def include_with_range?(value) if value.is_a?(::Range) operator = exclude_end? ? :< : :<= @@ -17,8 +16,7 @@ module ActiveSupport #:nodoc: include_without_range?(value) end end - end end end -end
\ No newline at end of file +end diff --git a/activesupport/lib/active_support/core_ext/range/overlaps.rb b/activesupport/lib/active_support/core_ext/range/overlaps.rb index 672e97fca4..80ed1bba9d 100644 --- a/activesupport/lib/active_support/core_ext/range/overlaps.rb +++ b/activesupport/lib/active_support/core_ext/range/overlaps.rb @@ -1,14 +1,12 @@ module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Range #:nodoc: - # Check if Ranges overlap + # Check if Ranges overlap. module Overlaps - def overlaps?(other) include?(other.first) || other.include?(first) - end - + end end end end -end
\ No newline at end of file +end |