class FactoryBot::Callback

Attributes

block[R]
name[R]

Public Class Methods

new(name, block) click to toggle source
# File lib/factory_bot/callback.rb, line 5
def initialize(name, block)
  @name = name.to_sym
  @block = block
end

Public Instance Methods

==(other) click to toggle source
# File lib/factory_bot/callback.rb, line 18
def ==(other)
  name == other.name &&
    block == other.block
end
run(instance, evaluator) click to toggle source
# File lib/factory_bot/callback.rb, line 10
def run(instance, evaluator)
  case block.arity
  when 1, -1, -2 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

Private Instance Methods

syntax_runner() click to toggle source
# File lib/factory_bot/callback.rb, line 29
def syntax_runner
  @syntax_runner ||= SyntaxRunner.new
end