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) ⇒ Object
- .type_of(action, method) ⇒ Object
Class Method Details
.execute(action, method, params = nil) ⇒ Object
30 31 32 33 |
# File 'lib/ext_direct/service/provider.rb', line 30 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
21 22 23 |
# File 'lib/ext_direct/service/provider.rb', line 21 def exist?(action, method) (@@store[action.to_sym] and @@store[action.to_sym][method.to_sym]) end |
.fetch ⇒ Object
17 18 19 |
# File 'lib/ext_direct/service/provider.rb', line 17 def fetch @@store end |
.register(type, action, method, proc) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ext_direct/service/provider.rb', line 7 def register(type, action, method, proc) 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 end |
.type_of(action, method) ⇒ Object
25 26 27 28 |
# File 'lib/ext_direct/service/provider.rb', line 25 def type_of(action, method) false unless exist?(action, method) @@store[action.to_sym][method.to_sym][:type] end |