Class: ActiverecordHoarder::Batch
- Inherits:
-
Object
- Object
- ActiverecordHoarder::Batch
- Defined in:
- lib/activerecord_hoarder/batch.rb
Constant Summary collapse
- RECORD_DATE_FIELD =
"created_at"
Class Method Summary collapse
Instance Method Summary collapse
- #content_string ⇒ Object
- #date ⇒ Object
-
#initialize(record_data) ⇒ Batch
constructor
A new instance of Batch.
- #key ⇒ Object
Constructor Details
#initialize(record_data) ⇒ Batch
Returns a new instance of Batch.
9 10 11 12 |
# File 'lib/activerecord_hoarder/batch.rb', line 9 def initialize(record_data) @record_data = record_data @serializer = ::ActiverecordHoarder::Serializer end |
Class Method Details
.from_records(record_data) ⇒ Object
5 6 7 |
# File 'lib/activerecord_hoarder/batch.rb', line 5 def self.from_records(record_data) record_data.present? ? new(record_data) : nil end |
Instance Method Details
#content_string ⇒ Object
22 23 24 |
# File 'lib/activerecord_hoarder/batch.rb', line 22 def content_string @serializer.create_archive(@record_data) end |
#date ⇒ Object
14 15 16 |
# File 'lib/activerecord_hoarder/batch.rb', line 14 def date @date ||= @record_data.first[RECORD_DATE_FIELD].to_date end |
#key ⇒ Object
18 19 20 |
# File 'lib/activerecord_hoarder/batch.rb', line 18 def key @key ||= ::ActiverecordHoarder::StorageKey.from_date(date, @serializer.extension) end |