Sha256: bc76d1cbf3cff3c81e75b9fad249523ccb47529b1e57b5581680e6015b259947

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

module CassandraMapper::Identity
  module ClassMethods
    def key(attribute = nil)
      @cassandra_mapper_key = attribute if attribute
      @cassandra_mapper_key ||= default_key_name
    end

    def default_key_name
      :key
    end
  end

  def self.included(klass)
    klass.extend ClassMethods
  end

  def key
    read_attribute(self.class.key)
  end

  def new_record=(flag)
    @cassandra_mapper_new_record = (flag && true) || false
  end

  def new_record?
    @cassandra_mapper_new_record = true unless defined? @cassandra_mapper_new_record
    @cassandra_mapper_new_record
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cassandra_mapper-0.0.1 lib/cassandra_mapper/identity.rb