Class: ExtDirect::Service::Provider
- Inherits:
-
Object
- Object
- ExtDirect::Service::Provider
- Defined in:
- lib/ext_direct/service/provider.rb
Constant Summary collapse
- @@store =
{}
Class Method Summary collapse
- .execute(action, method, params = nil) ⇒ Object
- .exist?(action, method) ⇒ Boolean
- .fetch ⇒ Object
- .register(type, action, method, proc, params = {}) ⇒ Object
- .type_of(action, method) ⇒ Object
Class Method Details
.execute(action, method, params = nil) ⇒ Object
31 32 33 34 |
# File 'lib/ext_direct/service/provider.rb', line 31 def execute(action, method, params = nil) raise "Unknown action or method" unless exist?(action, method) @@store[action.to_sym][method.to_sym][:proc].call(params) end |
.exist?(action, method) ⇒ Boolean
22 23 24 |
# File 'lib/ext_direct/service/provider.rb', line 22 def exist?(action, method) (@@store[action.to_sym] and @@store[action.to_sym][method.to_sym]) end |
.fetch ⇒ Object
18 19 20 |
# File 'lib/ext_direct/service/provider.rb', line 18 def fetch @@store end |
.register(type, action, method, proc, params = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ext_direct/service/provider.rb', line 7 def register(type, action, method, proc, params = {}) action = action.to_sym method = method.to_sym @@store[action] = {} unless @@store[action] @@store[action][method] = {} unless @@store[action][method] @@store[action][method][:type] = type @@store[action][method][:proc] = proc @@store[action][method][:params] = params end |
.type_of(action, method) ⇒ Object
26 27 28 29 |
# File 'lib/ext_direct/service/provider.rb', line 26 def type_of(action, method) false unless exist?(action, method) @@store[action.to_sym][method.to_sym][:type] end |