Skip to content

Commit

Permalink
Use active support's Hash#except
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Oct 20, 2011
1 parent 50a66d0 commit eb73dc1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/factory_girl/proxy.rb
@@ -1,3 +1,5 @@
require "active_support/core_ext/hash/except"

module FactoryGirl
class Proxy #:nodoc:
def initialize(klass, callbacks = [])
Expand Down
6 changes: 1 addition & 5 deletions lib/factory_girl/proxy/build.rb
Expand Up @@ -25,7 +25,7 @@ def associate(name, factory_name, overrides)
def association(factory_name, overrides = {})
method = get_method(overrides[:method])
factory = FactoryGirl.factory_by_name(factory_name)
factory.run(method, remove_method(overrides))
factory.run(method, overrides.except(:method))
end

def result(to_create)
Expand All @@ -35,10 +35,6 @@ def result(to_create)

private

def remove_method(overrides)
overrides.dup.delete_if {|key, value| key == :method}
end

def get_method(method)
case method
when :build then Proxy::Build
Expand Down
6 changes: 1 addition & 5 deletions lib/factory_girl/proxy/stub.rb
Expand Up @@ -65,11 +65,7 @@ def associate(name, factory_name, overrides)

def association(factory_name, overrides = {})
factory = FactoryGirl.factory_by_name(factory_name)
factory.run(Proxy::Stub, remove_method(overrides))
end

def remove_method(overrides)
overrides.dup.delete_if {|key, value| key == :method}
factory.run(Proxy::Stub, overrides.except(:method))
end

def result(to_create)
Expand Down

0 comments on commit eb73dc1

Please sign in to comment.