Class: FactoryBot::Decorator

Inherits:
BasicObject
Defined in:
lib/factory_bot/decorator.rb,
lib/factory_bot/decorator/attribute_hash.rb,
lib/factory_bot/decorator/new_constructor.rb,
lib/factory_bot/decorator/invocation_tracker.rb,
lib/factory_bot/decorator/disallows_duplicates_registry.rb

Defined Under Namespace

Classes: AttributeHash, DisallowsDuplicatesRegistry, InvocationTracker, NewConstructor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ Decorator

Returns a new instance of Decorator.


5
6
7
# File 'lib/factory_bot/decorator.rb', line 5

def initialize(component)
  @component = component
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing


20
21
22
# File 'lib/factory_bot/decorator.rb', line 20

def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
  @component.send(name, *args, &block)
end

Class Method Details

.const_missing(name) ⇒ Object


33
34
35
# File 'lib/factory_bot/decorator.rb', line 33

def self.const_missing(name)
  ::Object.const_get(name)
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

29
30
31
# File 'lib/factory_bot/decorator.rb', line 29

def respond_to_missing?(name, include_private = false)
  @component.respond_to?(name, true) || super
end

#send(symbol, *args, &block) ⇒ Object


24
25
26
# File 'lib/factory_bot/decorator.rb', line 24

def send(symbol, *args, &block)
  __send__(symbol, *args, &block)
end