Module: ActivePresenter::ProxyMethods
Overview
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/proxy.rb', line 49
def method_missing(sym, *args)
syms = sym.to_s
if syms.match(/.=$/)
key = syms.chop
gen_methods(key)
self.send("#{key}=", args.from_args)
else
key = sym.to_s
gen_methods(key)
self.send("#{key}", args.from_args)
end
end
|
Instance Method Details
#add_is_a(x) ⇒ Object
43
44
45
46
47
|
# File 'lib/proxy.rb', line 43
def add_is_a(x)
is_a_list << x
is_a_list.flatten!
is_a_list.uniq!
end
|
#create_method(name, &block) ⇒ Object
31
32
33
|
# File 'lib/proxy.rb', line 31
def create_method(name, &block)
self.class.send(:define_method, name, &block)
end
|
#initialize(options = {}, is_a_list = []) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/proxy.rb', line 24
def initialize(options = {}, is_a_list = [])
if !options.nil? && options.is_a?(Hash)
options.each_pair {|k,v| self.send("#{k}=", v)}
end
self.add_is_a(is_a_list)
end
|
#is_a?(x) ⇒ Boolean
35
36
37
|
# File 'lib/proxy.rb', line 35
def is_a?(x)
test_is_a?(x) ? true : super(x)
end
|
#kind_of?(x) ⇒ Boolean
39
40
41
|
# File 'lib/proxy.rb', line 39
def kind_of?(x)
test_is_a?(x) ? true : super(x)
end
|