Skip to content

Commit

Permalink
Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Sep 3, 2011
1 parent 386848d commit de2d499
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/factory_girl/attribute.rb
Expand Up @@ -29,6 +29,10 @@ def association?
false
end

def callback?
false
end

def priority
1
end
Expand Down
4 changes: 4 additions & 0 deletions lib/factory_girl/attribute/callback.rb
Expand Up @@ -9,6 +9,10 @@ def initialize(name, block)
def add_to(proxy)
proxy.add_callback(name, @block)
end

def callback?
true
end
end
end
end
20 changes: 9 additions & 11 deletions lib/factory_girl/attribute/implicit.rb
Expand Up @@ -22,18 +22,16 @@ def factory
private

def implementation
@implementation ||= resolve_name
end

def resolve_name
if FactoryGirl.factories.registered?(name)
Attribute::Association.new(name, name, {})
elsif FactoryGirl.sequences.registered?(name)
Attribute::Sequence.new(name, name)
else
Attribute::Trait.new(name, @factory)
end
@implementation ||=
if FactoryGirl.factories.registered?(name)
Attribute::Association.new(name, name, {})
elsif FactoryGirl.sequences.registered?(name)
Attribute::Sequence.new(name, name)
else
Attribute::Trait.new(name, @factory)
end
end
end

end
end
5 changes: 2 additions & 3 deletions lib/factory_girl/attribute_list.rb
Expand Up @@ -85,9 +85,8 @@ def flattened_attributes
end

def find_attribute(attribute_name)
@attributes.values.flatten.detect do |attribute|
attribute.name == attribute_name &&
!attribute.is_a?(FactoryGirl::Attribute::Callback)
@attributes.values.flatten.reject(&:callback?).detect do |attribute|
attribute.name == attribute_name
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/factory_girl/attribute/callback_spec.rb
Expand Up @@ -9,6 +9,8 @@

its(:name) { should == name }

it { should be_callback }

it "set its callback on a proxy" do
proxy.stubs(:add_callback)
subject.add_to(proxy)
Expand Down
1 change: 1 addition & 0 deletions spec/factory_girl/attribute_spec.rb
Expand Up @@ -7,6 +7,7 @@

its(:name) { should == name.to_sym }
it { should_not be_association }
it { should_not be_callback }

it "doesn't set any attributes on a proxy when added" do
proxy.stubs(:set)
Expand Down

0 comments on commit de2d499

Please sign in to comment.