Module: CassandraArchive
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cassandra_archive.rb,
lib/cassandra_archive/helper.rb,
lib/cassandra_archive/version.rb
Defined Under Namespace
Modules: ClassMethods, Helper
Constant Summary
collapse
- VERSION =
'0.2.0'
Instance Method Summary
collapse
Instance Method Details
#archive ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/cassandra_archive.rb', line 16
def archive
time = DateTime.current
cassandra_timestamp = Helper.timestamp(time)
unix_timestamp = time.to_i.to_s
cassandra_attributes = archived_attributes.merge('archived_at' => unix_timestamp)
::CASSANDRA_CLIENT.insert('DeletedRecords', self.class.table_name, {cassandra_timestamp.to_s => cassandra_attributes})
end
|
#archived_attributes ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/cassandra_archive.rb', line 31
def archived_attributes
cassandra_archive_attributes.inject({}) do |hash, attribute|
value = send(attribute).to_s
cassandra_encoded_value = Helper.encode_for_cassandra(value)
hash[attribute.to_s] = cassandra_encoded_value
hash
end
end
|
#cassandra_archive_attributes ⇒ Object
26
27
28
29
|
# File 'lib/cassandra_archive.rb', line 26
def cassandra_archive_attributes
attributes.keys
end
|