Class: Maybelline::Maybe

Inherits:
BasicObject
Defined in:
lib/maybelline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Maybe

Returns a new instance of Maybe.



19
20
21
22
23
# File 'lib/maybelline.rb', line 19

def initialize(object)
  @__object__ = object

  ::Object.new.send :throw, :nothing if @__object__.nil?      
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



41
42
43
44
45
# File 'lib/maybelline.rb', line 41

def method_missing(method, *args)
  result = @__object__.__send__(method, *args)

  Maybe.new(result)
end

Instance Attribute Details

#__object__Object (readonly)

Returns the value of attribute __object__.



17
18
19
# File 'lib/maybelline.rb', line 17

def __object__
  @__object__
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/maybelline.rb', line 25

def ==(other)
  @__object__ == other
end

#equal?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/maybelline.rb', line 29

def equal?(other)
  @__object__.equal?(other)
end

#instance_eval(*args) ⇒ Object



33
34
35
# File 'lib/maybelline.rb', line 33

def instance_eval(*args)
  @__object__.instance_eval(*args)
end

#instance_exec(*args) ⇒ Object



37
38
39
# File 'lib/maybelline.rb', line 37

def instance_exec(*args)
  @__object__.instance_exec(*args)
end