Sha256: 12331d2a0c1677fc2282648a7113d9280d3203b2f2b17ee532a8ae24fe1ea27d

Contents?: true

Size: 442 Bytes

Versions: 11

Compression:

Stored size: 442 Bytes

Contents

module Superstore
  module AttributeMethods
    module PrimaryKey
      extend ActiveSupport::Concern

      module ClassMethods
        PRIMARY_KEY = 'id'
        def primary_key
          PRIMARY_KEY
        end
      end

      def id
        @id ||= self.class._generate_key(self)
      end

      def id=(id)
        @id = id
      end

      def attributes
        super.update(self.class.primary_key => id)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
superstore-2.4.4 lib/superstore/attribute_methods/primary_key.rb
superstore-2.4.3 lib/superstore/attribute_methods/primary_key.rb
superstore-2.4.2 lib/superstore/attribute_methods/primary_key.rb
superstore-2.4.1 lib/superstore/attribute_methods/primary_key.rb
superstore-2.4.0 lib/superstore/attribute_methods/primary_key.rb
superstore-2.3.0 lib/superstore/attribute_methods/primary_key.rb
superstore-2.2.0 lib/superstore/attribute_methods/primary_key.rb
superstore-2.1.3 lib/superstore/attribute_methods/primary_key.rb
superstore-2.1.2 lib/superstore/attribute_methods/primary_key.rb
superstore-2.1.1 lib/superstore/attribute_methods/primary_key.rb
superstore-2.1.0 lib/superstore/attribute_methods/primary_key.rb