Class: Faith::MixinInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/faith/mixin_instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mixinObject

Returns the value of attribute mixin.



8
9
10
# File 'lib/faith/mixin_instance.rb', line 8

def mixin
  @mixin
end

#providedObject

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