Sha256: 36c2343ebfc4e8c04b842a091d1caf81b90f7548b0882b5220e83895c6ad1b30

Contents?: true

Size: 408 Bytes

Versions: 20

Compression:

Stored size: 408 Bytes

Contents

module Superstore
  module AttributeMethods
    module PrimaryKey
      extend ActiveSupport::Concern

      module ClassMethods
        def primary_key
          'id'
        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

20 entries across 20 versions & 1 rubygems

Version Path
superstore-2.0.1 lib/superstore/attribute_methods/primary_key.rb
superstore-2.0.0 lib/superstore/attribute_methods/primary_key.rb
superstore-1.2.0 lib/superstore/attribute_methods/primary_key.rb
superstore-1.1.4 lib/superstore/attribute_methods/primary_key.rb
superstore-1.1.3 lib/superstore/attribute_methods/primary_key.rb
superstore-1.1.2 lib/superstore/attribute_methods/primary_key.rb
superstore-1.1.1 lib/superstore/attribute_methods/primary_key.rb
superstore-1.1.0 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.12 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.11 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.10 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.9 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.8 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.7 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.6 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.5 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.4 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.3 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.2 lib/superstore/attribute_methods/primary_key.rb
superstore-1.0.0 lib/superstore/attribute_methods/primary_key.rb