Class: Rudash::ChainUtils::ChainWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/chain_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, ru_) ⇒ ChainWrapper

Returns a new instance of ChainWrapper.



6
7
8
9
# File 'lib/utils/chain_wrapper.rb', line 6

def initialize(value, ru_)
  @value = value
  @ru_ = ru_
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &_block) ⇒ Object



11
12
13
14
15
16
# File 'lib/utils/chain_wrapper.rb', line 11

def method_missing(method_name, *args, &_block)
  result = @ru_.public_send(method_name, @value, *args)
  self.class.new(result, @ru_)
rescue NameError
  raise NameError, "\"#{method_name}\" doesn't exist in Rudash"
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/utils/chain_wrapper.rb', line 4

def value
  @value
end