Class: Marty::ApiConfig
- Inherits:
-
Base
show all
- Defined in:
- app/models/marty/api_config.rb
Class Method Summary
collapse
Methods inherited from Base
get_final_attrs, get_struct_attrs, make_hash, make_openstruct, mcfly_pt
joins, old_joins
Class Method Details
.lookup(script, node, attr) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/models/marty/api_config.rb', line 4
def self.lookup(script, node, attr)
res = where('node IS NULL OR node = ?', node).
where('attr IS NULL OR attr = ?', attr).
order('node nulls last, attr nulls last').
find_by(script: script)
res && res.as_json.except('id',
'created_at',
'updated_at',
'script',
'node',
'attr').symbolize_keys
end
|
.multi_lookup(script, node, attrs) ⇒ Object
18
19
20
21
|
# File 'app/models/marty/api_config.rb', line 18
def self.multi_lookup(script, node, attrs)
(attrs.nil? ? [nil] : attrs).
map { |attr| lookup(script, node, attr).try { |x| x.unshift(attr) } }
end
|