lib/active_object/range.rb in active_object-2.5.2 vs lib/active_object/range.rb in active_object-3.0.0

- old
+ new

@@ -1,26 +1,22 @@ -class Range +module ActiveObject::Range def combine(other) to_a.concat(other.to_a) end - unless defined?(Rails) - def include_with_range?(other) - if other.is_a?(::Range) - operator = exclude_end? && !other.exclude_end? ? :< : :<= - include?(other.first) && other.last.send(operator, last) - else - include?(other) - end + def include_with_range?(other) + if other.is_a?(::Range) + operator = exclude_end? && !other.exclude_end? ? :< : :<= + include?(other.first) && other.last.send(operator, last) + else + include?(other) end end - unless defined?(Rails) - def overlaps?(other) - cover?(other.first) || other.cover?(first) - end + def overlaps?(other) + cover?(other.first) || other.cover?(first) end def sample to_a.sample end @@ -31,6 +27,8 @@ def within?(other) cover?(other.first) && cover?(other.last) end -end \ No newline at end of file +end + +Range.send(:include, ActiveObject::Range) if ActiveObject.configuration.autoload_range