Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Removed Enumerable patches
Browse files Browse the repository at this point in the history
* Not sure what I was thinking when I added these methods.  Patching
  Enumerable was a mistake for more than just this specific ticket.

[#1195 state:resolved]
  • Loading branch information
dkubb committed Feb 7, 2010
1 parent bec7d7b commit f5df62c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
3 changes: 1 addition & 2 deletions dm-core.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Dan Kubb"]
s.date = %q{2010-02-04}
s.date = %q{2010-02-07}
s.description = %q{Faster, Better, Simpler.}
s.email = %q{dan.kubb@gmail.com}
s.extra_rdoc_files = [
Expand Down Expand Up @@ -43,7 +43,6 @@ Gem::Specification.new do |s|
"lib/dm-core/associations/one_to_one.rb",
"lib/dm-core/associations/relationship.rb",
"lib/dm-core/collection.rb",
"lib/dm-core/core_ext/enumerable.rb",
"lib/dm-core/core_ext/kernel.rb",
"lib/dm-core/core_ext/symbol.rb",
"lib/dm-core/identity_map.rb",
Expand Down
1 change: 0 additions & 1 deletion lib/dm-core.rb
Expand Up @@ -65,7 +65,6 @@
require dir / 'transaction' # TODO: move to dm-more
require dir / 'version'

require dir / 'core_ext' / 'enumerable'
require dir / 'core_ext' / 'kernel' # TODO: do not load automatically
require dir / 'core_ext' / 'symbol' # TODO: do not load automatically

Expand Down
2 changes: 1 addition & 1 deletion lib/dm-core/adapters/data_objects_adapter.rb
Expand Up @@ -685,7 +685,7 @@ def comparison_statement(comparison, qualify)
else
return conditions_statement(comparison.foreign_key_mapping, qualify)
end
elsif comparison.slug == :in && value.empty?
elsif comparison.slug == :in && !value.any?
return [] # match everything
end

Expand Down
28 changes: 0 additions & 28 deletions lib/dm-core/core_ext/enumerable.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/dm-core/query/conditions/comparison.rb
Expand Up @@ -626,7 +626,7 @@ def valid_collection?(collection)

# @api private
def valid_range?(range)
(!range.empty? || negated?) && valid_for_subject?(range.first) && valid_for_subject?(range.last)
(range.any? || negated?) && valid_for_subject?(range.first) && valid_for_subject?(range.last)
end

# @api private
Expand Down
31 changes: 31 additions & 0 deletions lib/dm-core/query/conditions/operation.rb
Expand Up @@ -132,6 +132,17 @@ def slug
self.class.slug
end

# Get the first operand
#
# @return [AbstractOperation, AbstractComparison, Array]
# returns the first operand
#
# @api semipublic
def first
each { |operand| return operand }
nil
end

# Iterate through each operand in the operation
#
# @yield [operand]
Expand All @@ -149,6 +160,26 @@ def each
self
end

# Test to see if there are operands
#
# @return [Boolean]
# returns true if there are operands
#
# @api semipublic
def empty?
@operands.empty?
end

# Test to see if there is one operand
#
# @return [Boolean]
# true if there is only one operand
#
# @api semipublic
def one?
@operands.size == 1
end

# Test if the operation is valid
#
# @return [Boolean]
Expand Down

0 comments on commit f5df62c

Please sign in to comment.