module Traits::Model::Querying

Public Instance Methods

arel() click to toggle source
# File lib/traits/model/querying.rb, line 20
def arel
  active_record.arel_table
end
connection() click to toggle source
# File lib/traits/model/querying.rb, line 24
def connection
  active_record.connection
end
primary_key_attribute() click to toggle source
# File lib/traits/model/querying.rb, line 16
def primary_key_attribute
  @pk_attr ||= attributes[primary_key_name]
end
primary_key_name() click to toggle source
# File lib/traits/model/querying.rb, line 7
def primary_key_name
  # Sometimes table doesn't have primary key.
  # This might be many-to-many tables (HABTM).
  @pk_name ||= begin
    pk = active_record.primary_key
    pk.kind_of?(String) ? pk.to_sym : pk
  end
end
quoted_table_name() click to toggle source
# File lib/traits/model/querying.rb, line 32
def quoted_table_name
  @quote_table_name ||= connection.quote_table_name(active_record.table_name)
end
table_name() click to toggle source
# File lib/traits/model/querying.rb, line 28
def table_name
  @table_name ||= active_record.table_name
end
to_hash() click to toggle source
Calls superclass method
# File lib/traits/model/querying.rb, line 36
def to_hash
  super.merge!(
    table_name:        table_name,
    quoted_table_name: quoted_table_name,
    polymorphic_type:  polymorphic_type,
    primary_key_name:  primary_key_name
  )
end