Module: SmoothOperator::Delegation
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/smooth_operator/delegation.rb', line 9
def method_missing(method, *args, &block)
method_type, method_name = *parse_method(method)
result = case method_type
when :was
get_internal_data(method_name, :was)
when :changed
get_internal_data(method_name, :changed?)
when :setter
return push_to_internal_data(method_name, args.first)
else
if !self.class.strict_behaviour || known_attribute?(method_name)
return get_internal_data(method_name)
end
end
result.nil? ? super : result
end
|
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
5
6
7
|
# File 'lib/smooth_operator/delegation.rb', line 5
def respond_to?(method, include_private = false)
known_attribute?(method) ? true : super
end
|