Class: Faith::MixinInstance
- Inherits:
-
Object
- Object
- Faith::MixinInstance
- Defined in:
- lib/faith/mixin_instance.rb
Instance Attribute Summary collapse
-
#mixin ⇒ Object
Returns the value of attribute mixin.
-
#provided ⇒ Object
Returns the value of attribute provided.
Instance Method Summary collapse
-
#initialize(mixin, provided: {}) ⇒ MixinInstance
constructor
A new instance of MixinInstance.
- #method_missing(name, *args, &block) ⇒ Object
- #provide(**items) ⇒ Object
Constructor Details
#initialize(mixin, provided: {}) ⇒ MixinInstance
Returns a new instance of MixinInstance.
3 4 5 6 |
# File 'lib/faith/mixin_instance.rb', line 3 def initialize(mixin, provided: {}) @mixin = mixin @provided = provided end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
10 11 12 13 |
# File 'lib/faith/mixin_instance.rb', line 10 def method_missing(name, *args, &block) return provided[name] if provided.has_key?(name) && args.length.zero? && block.nil? super end |
Instance Attribute Details
#mixin ⇒ Object
Returns the value of attribute mixin.
8 9 10 |
# File 'lib/faith/mixin_instance.rb', line 8 def mixin @mixin end |
#provided ⇒ Object
Returns the value of attribute provided.
8 9 10 |
# File 'lib/faith/mixin_instance.rb', line 8 def provided @provided end |
Instance Method Details
#provide(**items) ⇒ Object
15 16 17 |
# File 'lib/faith/mixin_instance.rb', line 15 def provide(**items) provided.merge! items end |