Sha256: 754ab176b37813210bdfc5391bdede797ed0304574ee79bdb7098d0855b346aa

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

module ActiveRecord
  module Core
    def init_internals
      pk = self.class.primary_key

      # CPK
      #@attributes[pk] = nil unless @attributes.key?(pk)
      unless self.composite?
        @attributes[pk] = nil unless @attributes.key?(pk)
      end

      @aggregation_cache        = {}
      @association_cache        = {}
      @attributes_cache         = {}
      @readonly                 = false
      @destroyed                = false
      @marked_for_destruction   = false
      @destroyed_by_association = nil
      @new_record               = true
      @txn                      = nil
      @_start_transaction_state = {}
      @transaction_state        = nil
      @reflects_state           = [false]
    end

    def initialize_dup(other) # :nodoc:
      cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)
      self.class.initialize_attributes(cloned_attributes, :serialized => false)

      @attributes = cloned_attributes

      # CPK
      #@attributes[self.class.primary_key] = nil
      Array(self.class.primary_key).each {|key| @attributes[key] = nil}

      run_callbacks(:initialize) unless _initialize_callbacks.empty?

      @aggregation_cache = {}
      @association_cache = {}
      @attributes_cache  = {}

      @new_record  = true

      super
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.13 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.12 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.11 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.10 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.9 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.8 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.7 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.6 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.5 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.4 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.3 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.2 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.1 lib/composite_primary_keys/core.rb
composite_primary_keys-7.0.0 lib/composite_primary_keys/core.rb