Module: ActiveRecord::Collections::Collectable::Relation

Defined in:
lib/active_record/collections/collectable.rb

Instance Method Summary collapse

Instance Method Details

#collectionObject Also known as: collect



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_record/collections/collectable.rb', line 25

def collection
  # do this with a hash so that we don't cause the relation query to execute
  kollektion.from_hash({
    klass:      klass,
    select:     select_values,
    distinct:   distinct_value,
    joins:      joins_values,
    references: references_values,
    includes:   includes_values,
    where:      where_values.map { |v| v.is_a?(String) ? v : v.to_sql },
    group:      group_values.map { |v| (v.is_a?(String) || v.is_a?(Symbol)) ? v : v.to_sql },
    order:      order_values.map { |v| (v.is_a?(String) || v.is_a?(Symbol)) ? v : v.to_sql },
    bind:       bind_values.map { |b| {name: b.first.name, value: b.last} },
    limit:      limit_value,
    offset:     offset_value
  })
end

#kollektionObject



21
22
23
# File 'lib/active_record/collections/collectable.rb', line 21

def kollektion
  klass.kollektion
end