Class: Marty::ApiConfig
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Marty::ApiConfig
- Defined in:
- app/models/marty/api_config.rb
Constant Summary
Constants inherited from ActiveRecord::Base
ActiveRecord::Base::COUNT_SIG, ActiveRecord::Base::DISTINCT_SIG, ActiveRecord::Base::FIND_BY_SIG, ActiveRecord::Base::FIRST_SIG, ActiveRecord::Base::GROUP_SIG, ActiveRecord::Base::JOINS_SIG, ActiveRecord::Base::LAST_SIG, ActiveRecord::Base::LIMIT_SIG, ActiveRecord::Base::MCFLY_PT_SIG, ActiveRecord::Base::NOT_SIG, ActiveRecord::Base::ORDER_SIG, ActiveRecord::Base::PLUCK_SIG, ActiveRecord::Base::SELECT_SIG, ActiveRecord::Base::WHERE_SIG
Class Method Summary collapse
Methods inherited from Base
get_final_attrs, get_struct_attrs, make_hash, make_openstruct, mcfly_pt
Methods inherited from ActiveRecord::Base
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 |