Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Ruby 2.0 breakage caused by behavior changes to #respond_to? - fixes
  • Loading branch information
cheald committed Nov 3, 2012
1 parent 197c2f6 commit eb232a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/mongo_mapper/plugins/associations/proxy.rb
Expand Up @@ -90,7 +90,7 @@ def respond_to?(*args)
end

def send(method, *args)
if proxy_respond_to?(method)
if proxy_respond_to?(method, true)
super
else
load_target
Expand Down
16 changes: 8 additions & 8 deletions lib/mongo_mapper/plugins/dirty.rb
Expand Up @@ -23,13 +23,6 @@ def reload(*)
super.tap { clear_changes }
end

protected

# We don't call super here to avoid invoking #attributes, which builds a whole new hash per call.
def attribute_method?(attr_name)
keys.key?(attr_name) || !embedded_associations.detect {|a| a.name == attr_name }.nil?
end

def clear_changes
previous = changes
(block_given? ? yield : true).tap do |result|
Expand All @@ -40,6 +33,13 @@ def clear_changes
end
end

protected

# We don't call super here to avoid invoking #attributes, which builds a whole new hash per call.
def attribute_method?(attr_name)
keys.key?(attr_name) || !embedded_associations.detect {|a| a.name == attr_name }.nil?
end

private

def write_key(key, value)
Expand All @@ -55,4 +55,4 @@ def attribute_value_changed?(key_name)
end
end
end
end
end

0 comments on commit eb232a9

Please sign in to comment.