Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_extension.rb

Class Method Summary collapse

Class Method Details

.find_as_hashes(*args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hash_extension.rb', line 20

def find_as_hashes(*args)
  options = (
    args.respond_to?(:extract_options!) ?
    args.extract_options! : 
    extract_options_from_args!(args) # pre 2.0 compatibility
  )

  if options.include?(:include)
    raise ActiveRecord::StatementInvalid, "find_as_hashes cannot accept :include options!"
  end
  validate_find_options(options)
  set_readonly_option!(options)

  case args.first
  when :first
    find_initial_as_hashes(options)
  when :all
    find_every_as_hashes(options)
  else
    find_from_ids_as_hashes(args, options)
  end
end

.find_by_sql_as_hashes(sql) ⇒ Object



16
17
18
# File 'lib/hash_extension.rb', line 16

def find_by_sql_as_hashes(sql)
  connection.select_all(sanitize_sql(sql))
end