Sha256: fbb0a65a84ef00f9cd6012595556be446c004978dd18d67a9f57a4e80ca59d40

Contents?: true

Size: 528 Bytes

Versions: 8

Compression:

Stored size: 528 Bytes

Contents

class Marty::ApiConfig < Marty::Base
  validates_presence_of :script

  def self.lookup(script, node, attr)
    res = where(["script = ? AND (node IS NULL OR node = ?) "\
           "AND (attr IS NULL OR attr = ?)",
           script, node, attr]).
           order('node nulls last, attr nulls last').
           pluck(:logged, :validated, :id)
    res.first
  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

8 entries across 8 versions & 1 rubygems

Version Path
marty-1.0.35 app/models/marty/api_config.rb
marty-1.0.34 app/models/marty/api_config.rb
marty-1.0.33 app/models/marty/api_config.rb
marty-1.0.32 app/models/marty/api_config.rb
marty-1.0.31 app/models/marty/api_config.rb
marty-1.0.30 app/models/marty/api_config.rb
marty-1.0.29 app/models/marty/api_config.rb
marty-1.0.28 app/models/marty/api_config.rb