Sha256: 132a79085c9ab62874c91f82a037eff8e90fd0a2bd056456336368bfd6037ead

Contents?: true

Size: 469 Bytes

Versions: 21

Compression:

Stored size: 469 Bytes

Contents

require 'securerandom'

module CassandraObject
  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

21 entries across 21 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.1.1 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.1.0 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.20 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.19 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.18 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.17 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.16 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.15 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.14 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.13 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.12 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.11 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.10 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.9 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.8 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.7 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.6 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.5 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.4 lib/cassandra_object/identity.rb
extendi-cassandra_object-1.0.1 lib/cassandra_object/identity.rb