Class: FactoryGirl::Callback
- Inherits:
-
Object
- Object
- FactoryGirl::Callback
- Defined in:
- lib/factory_girl/callback.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, block) ⇒ Callback
constructor
A new instance of Callback.
- #run(instance, evaluator) ⇒ Object
Constructor Details
#initialize(name, block) ⇒ Callback
Returns a new instance of Callback.
5 6 7 8 9 |
# File 'lib/factory_girl/callback.rb', line 5 def initialize(name, block) @name = name.to_sym @block = block ensure_valid_callback_name! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/factory_girl/callback.rb', line 3 def name @name end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 |
# File 'lib/factory_girl/callback.rb', line 19 def ==(other) name == other.name && block == other.block end |
#run(instance, evaluator) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/factory_girl/callback.rb', line 11 def run(instance, evaluator) case block.arity when 1, -1 then syntax_runner.instance_exec(instance, &block) when 2 then syntax_runner.instance_exec(instance, evaluator, &block) else syntax_runner.instance_exec(&block) end end |