Class: Vend::BaseFactory
- Inherits:
-
Object
- Object
- Vend::BaseFactory
- Defined in:
- lib/vend/base_factory.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#target_class ⇒ Object
readonly
Returns the value of attribute target_class.
Instance Method Summary collapse
-
#initialize(client, target_class) ⇒ BaseFactory
constructor
A new instance of BaseFactory.
-
#method_missing(method_name, *args, &block) ⇒ Object
The main point of this factory class is to proxy methods to the target class and prepend client to the argument list.
- #respond_to?(method_name) ⇒ Boolean
Constructor Details
#initialize(client, target_class) ⇒ BaseFactory
Returns a new instance of BaseFactory.
5 6 7 8 |
# File 'lib/vend/base_factory.rb', line 5 def initialize(client, target_class) @target_class = target_class @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
The main point of this factory class is to proxy methods to the target class and prepend client to the argument list.
12 13 14 15 |
# File 'lib/vend/base_factory.rb', line 12 def method_missing(method_name, *args, &block) args.unshift(client) target_class.send(method_name, *args, &block) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/vend/base_factory.rb', line 3 def client @client end |
#target_class ⇒ Object (readonly)
Returns the value of attribute target_class.
3 4 5 |
# File 'lib/vend/base_factory.rb', line 3 def target_class @target_class end |
Instance Method Details
#respond_to?(method_name) ⇒ Boolean
17 18 19 20 |
# File 'lib/vend/base_factory.rb', line 17 def respond_to?(method_name) return true if target_class.respond_to?(method_name) super(method_name) end |