Class: RedBikini::Bikini
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/red_bikini/bikini.rb
Instance Method Summary
collapse
Constructor Details
#initialize(object) ⇒ Bikini
Returns a new instance of Bikini.
6
7
8
|
# File 'lib/red_bikini/bikini.rb', line 6
def initialize object
@__in_bikini__ = object
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
28
29
30
|
# File 'lib/red_bikini/bikini.rb', line 28
def method_missing method, *args
@__in_bikini__.public_send(object_method(method), *args)
end
|
Instance Method Details
#===(other) ⇒ Object
10
11
12
|
# File 'lib/red_bikini/bikini.rb', line 10
def === other
@__in_bikini__ === other
end
|
#_self ⇒ Object
14
15
16
|
# File 'lib/red_bikini/bikini.rb', line 14
def _self
@__in_bikini__
end
|
#object_method(method) ⇒ Object
18
19
20
|
# File 'lib/red_bikini/bikini.rb', line 18
def object_method method
original(method) or setter_imitated_by(method)
end
|
#original(method) ⇒ Object
21
22
23
|
# File 'lib/red_bikini/bikini.rb', line 21
def original method
@__in_bikini__.respond_to?(method, true) and method
end
|
#respond_to_missing?(method, *args) ⇒ Boolean
25
26
27
|
# File 'lib/red_bikini/bikini.rb', line 25
def respond_to_missing? method, *args
@__in_bikini__.respond_to?(object_method(method), *args)
end
|
#setter_imitated_by(method) ⇒ Object
33
34
35
36
37
|
# File 'lib/red_bikini/bikini.rb', line 33
def setter_imitated_by method
[/set_(?<attr>\w+)/,/(?<attr>\w+)(_are|_is)/].find do |setter_matcher|
String(method).match(setter_matcher){|match| return match['attr'] + ?= }
end
end
|