Sha256: 14f882e72bbaf2d821795f7810ce4aa4a6b55cdbea1df3d181e7f8993b41675a
Contents?: true
Size: 731 Bytes
Versions: 40
Compression:
Stored size: 731 Bytes
Contents
class Marty::ApiConfig < Marty::Base validates_presence_of :script 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 def self.multi_lookup(script, node, attrs) (attrs.nil? ? [nil] : attrs). map { |attr| lookup(script, node, attr).try { |x| x.unshift(attr) } } end end
Version data entries
40 entries across 40 versions & 1 rubygems