Module: StateStore::Extension::InstanceMethods
- Defined in:
- lib/state_store/extension.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/state_store/extension.rb', line 72
def method_missing(method_name, *args)
state_method_name = method_name.to_s.match(/^has_(\w+)\?$/)
state_method_name = state_method_name && state_method_name[1].to_sym
if state_method_name
options = self.class.states_stores_options.detect{|key,value| value[:in].to_sym == state_method_name}
options = options && options[1]
if options
instance_method_name = options && options[:in]
self.class.states_stores[options[:as]].has_status?(args[0],self.send(instance_method_name))
else
super
end
else
super
end
end
|
Class Method Details
.included(base) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/state_store/extension.rb', line 71
def self.included(base)
def method_missing(method_name, *args)
state_method_name = method_name.to_s.match(/^has_(\w+)\?$/)
state_method_name = state_method_name && state_method_name[1].to_sym
if state_method_name
options = self.class.states_stores_options.detect{|key,value| value[:in].to_sym == state_method_name}
options = options && options[1]
if options
instance_method_name = options && options[:in]
self.class.states_stores[options[:as]].has_status?(args[0],self.send(instance_method_name))
else
super
end
else
super
end
end
end
|