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

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

Instance Method Summary collapse

Instance Method Details

#collectionObject Also known as: to_collection



38
39
40
41
42
43
44
# File 'lib/active_record/collections/collectable.rb', line 38

def collection
  # do this with a hash so that we don't cause the relation query to execute
  c = kollektion.from_hash(values_hash)
  # TODO do we even need to do from_hash here? can we just create a new from_relation method instead that re-uses the same relation if we're already loaded?
  c.instance_variable_set(:@relation, self) if loaded?
  c
end

#kollektionObject



29
30
31
# File 'lib/active_record/collections/collectable.rb', line 29

def kollektion
  klass.kollektion
end

#values_hashObject Also known as: to_values_hash



33
34
35
# File 'lib/active_record/collections/collectable.rb', line 33

def values_hash
  ActiveRecord::Collections::Serializer.to_hash(values.merge({collectable: klass}))
end