Class: Maybe
- Inherits:
-
Object
show all
- Defined in:
- lib/terminal/emojify/maybe.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/terminal/emojify/maybe.rb', line 14
def method_missing(method_name, *arguments, &block)
value = nil
if @object.respond_to?(method_name)
value = @object.send(method_name, *arguments, &block)
end
self.class.wrap(value)
end
|
Class Method Details
.wrap(object) ⇒ Object
2
3
4
5
6
7
8
|
# File 'lib/terminal/emojify/maybe.rb', line 2
def self.wrap(object)
if object
Some.new(object)
else
None.new
end
end
|
Instance Method Details
#respond_to?(method_name, include_private = false) ⇒ Boolean
10
11
12
|
# File 'lib/terminal/emojify/maybe.rb', line 10
def respond_to?(method_name, include_private = false)
super || @object.respond_to?(method_name, include_private)
end
|