Class: Agrippa::Maybe

Inherits:
Proxy
  • Object
show all
Defined in:
lib/agrippa/maybe.rb

Instance Attribute Summary

Attributes inherited from Proxy

#proxied_methods

Instance Method Summary collapse

Methods inherited from Proxy

#_, #__set_proxied_methods, #_deep_value, #_value, #initialize, #is_a?, #proxied_method?, #respond_to?

Methods included from Methods

included, name

Constructor Details

This class inherits a constructor from Agrippa::Proxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/agrippa/maybe.rb', line 5

def method_missing(method, *args, &block)
    return(self) if @value.nil?
    output = begin
        @value.send(method, *args, &block)
    rescue ::NoMethodError
        nil
    end
    return(output) unless proxied_method?(method)
    @value = output
    __chain(@value)
end