Class: Magic::Decorator::Base
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Magic::Decorator::Base
show all
- Extended by:
- Lookup
- Includes:
- Magic::Decoratable
- Defined in:
- lib/magic/decorator/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#decorate, #decorate!, #decorated
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/magic/decorator/base.rb', line 39
def method_missing(method, ...)
return super if method.start_with? 'to_' return super if method.start_with? '_'
if block_given?
super { |*args| yield *args.map(&:decorated) }
else
super
end.decorated
rescue NoMethodError => error
__raise__ error.class.new(
error.message.sub(self.class.name, __getobj__.class.name),
error.name,
error.args,
receiver: __getobj__
).tap {
_1.set_backtrace error.backtrace[2..] }
end
|
Class Method Details
.name_for(object_class) ⇒ Object
12
|
# File 'lib/magic/decorator/base.rb', line 12
def name_for(object_class) = "#{object_class}Decorator"
|
Instance Method Details
#decorated? ⇒ Boolean
30
|
# File 'lib/magic/decorator/base.rb', line 30
def decorated? = true
|