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



9
10
11
# File 'lib/factory_bot/decorator.rb', line 9

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

Class Method Details

.const_missing(name) ⇒ Object



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

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

Instance Method Details

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

Returns:

  • (Boolean)


13
14
15
# File 'lib/factory_bot/decorator.rb', line 13

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

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



17
18
19
# File 'lib/factory_bot/decorator.rb', line 17

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