Sha256: 63d72fde687da45d153bc5f17d81569ea90f0c2c7cd2ec5b6dcf142de71a157a
Contents?: true
Size: 735 Bytes
Versions: 11
Compression:
Stored size: 735 Bytes
Contents
class Marty::ApiConfig < Marty::Base validates :script, presence: true 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
11 entries across 11 versions & 1 rubygems