Class: TheGrid::Api::Command
- Inherits:
-
Object
- Object
- TheGrid::Api::Command
show all
- Defined in:
- lib/the_grid/api/command.rb
Defined Under Namespace
Classes: BatchRemove, BatchUpdate, Filter, Paginate, Search, Sort
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.build(cmd) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/the_grid/api/command.rb', line 25
def self.build(cmd)
scope = scopes.detect do |scope|
"#{scope}/#{cmd}".camelize.constantize rescue nil
end
raise ArgumentError, %{ Command "#{cmd}" is unknown } if scope.nil?
"#{scope}/#{cmd}".camelize.constantize.new
end
|
.find(cmd) ⇒ Object
12
13
14
15
|
# File 'lib/the_grid/api/command.rb', line 12
def self.find(cmd)
@@commands ||= {}
@@commands[cmd] ||= build(cmd)
end
|
.register_lookup_scope(scope) ⇒ Object
17
18
19
|
# File 'lib/the_grid/api/command.rb', line 17
def self.register_lookup_scope(scope)
scopes.unshift(scope).uniq!
end
|
.scopes ⇒ Object
21
22
23
|
# File 'lib/the_grid/api/command.rb', line 21
def self.scopes
@@scopes ||= ["the_grid/api/command"]
end
|
Instance Method Details
#batch? ⇒ Boolean
37
38
39
|
# File 'lib/the_grid/api/command.rb', line 37
def batch?
@is_batch ||= self.class.name.demodulize.starts_with?('Batch')
end
|
#contextualize(relation, params) ⇒ Object
41
42
43
|
# File 'lib/the_grid/api/command.rb', line 41
def contextualize(relation, params)
{}
end
|
#execute_on(relation, params) ⇒ Object
33
34
35
|
# File 'lib/the_grid/api/command.rb', line 33
def execute_on(relation, params)
run_on(relation, configure(relation, params))
end
|