Skip to content

Commit

Permalink
Simplify AttributeList
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Nov 28, 2011
1 parent 17eacf0 commit 56a6f67
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions lib/factory_girl/attribute_list.rb
Expand Up @@ -20,10 +20,7 @@ def each(&block)

def apply_attributes(attributes_to_apply)
attributes_to_apply.each do |attribute|
new_attribute = find_attribute(attribute.name) || attribute
delete_attribute(attribute.name)

add_attribute new_attribute
add_attribute(attribute) unless attribute_defined?(attribute.name)
end
end

Expand All @@ -47,17 +44,9 @@ def ensure_attribute_not_self_referencing!(attribute)
end

def attribute_defined?(attribute_name)
!!find_attribute(attribute_name)
end

def find_attribute(attribute_name)
@attributes.detect do |attribute|
@attributes.any? do |attribute|
attribute.name == attribute_name
end
end

def delete_attribute(attribute_name)
@attributes.delete_if {|attrib| attrib.name == attribute_name }
end
end
end

0 comments on commit 56a6f67

Please sign in to comment.