Class: Marty::ApiConfig

Inherits:
Base show all
Defined in:
app/models/marty/api_config.rb

Constant Summary

Constants inherited from Base

Base::COUNT_SIG, Base::DISTINCT_SIG, Base::FIRST_SIG, Base::GROUP_SIG, Base::JOINS_SIG, Base::LAST_SIG, Base::LIMIT_SIG, Base::MCFLY_PT_SIG, Base::NOT_SIG, Base::ORDER_SIG, Base::PLUCK_SIG, Base::SELECT_SIG, Base::WHERE_SIG

Class Method Summary collapse

Methods inherited from Base

mcfly_pt

Methods inherited from ActiveRecord::Base

joins, old_joins

Class Method Details

.lookup(script, node, attr) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/models/marty/api_config.rb', line 4

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, :input_validated, :output_validated, :strict_validate,
               :id)
  res.first
end

.multi_lookup(script, node, attrs) ⇒ Object



13
14
15
16
# File 'app/models/marty/api_config.rb', line 13

def self.multi_lookup(script, node, attrs)
  (attrs.nil? ? [nil] : attrs).
    map { |attr| lookup(script, node, attr).try{|x| x.unshift(attr) }}
end