Sha256: 9d7431348d0d439997e84647ea0271182cd44d6f6fcf4dba547d9b0518b61185

Contents?: true

Size: 464 Bytes

Versions: 33

Compression:

Stored size: 464 Bytes

Contents

require 'securerandom'

module Superstore
  module Identity
    extend ActiveSupport::Concern

    included do
      class_attribute :key_generator

      key do
        SecureRandom.uuid.tr('-','')
      end
    end

    module ClassMethods
      # Define a key generator. Default is UUID.
      def key(&block)
        self.key_generator = block
      end

      def _generate_key(object)
        object.instance_eval(&key_generator)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
superstore-3.0.0 lib/superstore/identity.rb
superstore-2.5.0 lib/superstore/identity.rb
superstore-2.4.4 lib/superstore/identity.rb
superstore-2.4.3 lib/superstore/identity.rb
superstore-2.4.2 lib/superstore/identity.rb
superstore-2.4.1 lib/superstore/identity.rb
superstore-2.4.0 lib/superstore/identity.rb
superstore-2.3.0 lib/superstore/identity.rb
superstore-2.2.0 lib/superstore/identity.rb
superstore-2.1.3 lib/superstore/identity.rb
superstore-2.1.2 lib/superstore/identity.rb
superstore-2.1.1 lib/superstore/identity.rb
superstore-2.1.0 lib/superstore/identity.rb
superstore-2.0.1 lib/superstore/identity.rb
superstore-2.0.0 lib/superstore/identity.rb
superstore-1.2.0 lib/superstore/identity.rb
superstore-1.1.4 lib/superstore/identity.rb
superstore-1.1.3 lib/superstore/identity.rb
superstore-1.1.2 lib/superstore/identity.rb
superstore-1.1.1 lib/superstore/identity.rb