core/rails/lib/api_helper.rb
# Helper to allow API to use ID or name
Helper to allow API to use ID or name
Helper to allow API to use ID or name
def find_key(key)
      col,key = case
                when db_id?(key) then [:id, key.to_i]
                when UUID_RE.match(key) then [:uuid, key]
                when key.is_a?(ActiveRecord::Base) then [:id, key.id]
                when self.respond_to?(:name_column) then [name_column, key]
                else [:name, key]
                end
      begin
        find_by!(col => key)
      rescue ActiveRecord::RecordNotFound => e
        e.rebar_model = self
        e.rebar_column = col
        e.rebar_key = key
        raise e
      end
    end
def find_key ( key ) col , key = case when db_id? ( key ) then [ :id , key . to_i ] when UUID_RE . match ( key ) then [ :uuid , key ] when key . is_a? ( ActiveRecord :: Base ) then [ :id , key . id ] when self . respond_to? ( :name_column ) then [ name_column , key ] else [ :name , key ] end begin find_by! ( col => key ) rescue ActiveRecord :: RecordNotFound => e e . rebar_model = self e . rebar_column = col e . rebar_key = key raise e end end
Helper to allow API to use ID or name
Helper to allow API to use ID or name
key
<not_specific>