module FindAsHashes::Relation

Public Instance Methods

all_as_hashes() click to toggle source
# File lib/find_as_hashes.rb, line 8
def all_as_hashes
  fix_prepared_statement do
    connection.select_all(self.joins(self.includes_values).to_sql).to_a
  end
end
first_as_hash() click to toggle source
# File lib/find_as_hashes.rb, line 14
def first_as_hash
  fix_prepared_statement do
    relation_stack = limit(1)
    connection.select_one(relation_stack.joins(relation_stack.includes_values).to_sql)
  end
end

Private Instance Methods

fix_prepared_statement() { || ... } click to toggle source
# File lib/find_as_hashes.rb, line 21
def fix_prepared_statement
  if connection.respond_to?(:unprepared_statement)
    connection.unprepared_statement{ yield }
  else
    yield
  end
end