Class: Ick::Wrapper
- Inherits:
-
Object
show all
- Defined in:
- lib/ick/wrap.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value, *additional_attributes) ⇒ Wrapper
Returns a new instance of Wrapper.
12
13
14
|
# File 'lib/ick/wrap.rb', line 12
def initialize(value, *additional_attributes)
@value = value
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
28
29
30
|
# File 'lib/ick/wrap.rb', line 28
def method_missing(sym, *args, &block)
__rewrap__(__invoke__(sym, *args, &block))
end
|
Class Method Details
.is_contagious ⇒ Object
35
36
37
38
39
|
# File 'lib/ick/wrap.rb', line 35
def self.is_contagious
define_method(:__rewrap__) { |value|
self.__class.new(value)
}
end
|
.is_not_contagious ⇒ Object
41
42
43
|
# File 'lib/ick/wrap.rb', line 41
def self.is_not_contagious
define_method(:__rewrap__) { |value| value }
end
|
Instance Method Details
#__invocation__ ⇒ Object
19
20
21
|
# File 'lib/ick/wrap.rb', line 19
def __invocation__
@invocation
end
|
#__invoke__(sym, *args, &block) ⇒ Object
25
26
27
|
# File 'lib/ick/wrap.rb', line 25
def __invoke__(sym, *args, &block)
raise 'implemented by subclass'
end
|
#__respond_to? ⇒ Object
5
|
# File 'lib/ick/wrap.rb', line 5
alias :__respond_to? :respond_to?
|
#__rewrap__(value) ⇒ Object
22
23
24
|
# File 'lib/ick/wrap.rb', line 22
def __rewrap__(value)
raise 'implemented by subclass'
end
|
#__value__ ⇒ Object
16
17
18
|
# File 'lib/ick/wrap.rb', line 16
def __value__
@value
end
|
#respond_to?(sym) ⇒ Boolean
31
32
33
|
# File 'lib/ick/wrap.rb', line 31
def respond_to?(sym)
@value.respond_to?(sym) || self.__respond_to?(sym)
end
|