Class: Airspace::Dataset
- Inherits:
-
Object
- Object
- Airspace::Dataset
- Includes:
- HasMetadata, InfoKeys
- Defined in:
- lib/airspace/dataset.rb
Overview
This is the main input class that can persist data.
Constant Summary
Constants included from InfoKeys
InfoKeys::DATA_KEY, InfoKeys::METADATA_KEY, InfoKeys::SEPARATOR_CHAR
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Attributes included from HasMetadata
Instance Method Summary collapse
-
#initialize(client, id: nil, data: {}, pages: [], options: {}) ⇒ Dataset
constructor
A new instance of Dataset.
- #save ⇒ Object
Constructor Details
#initialize(client, id: nil, data: {}, pages: [], options: {}) ⇒ Dataset
Returns a new instance of Dataset.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/airspace/dataset.rb', line 23 def initialize(client, id: nil, data: {}, pages: [], options: {}) raise ArgumentError, 'client is required' unless client @client = client @data = data || {} @id = id || SecureRandom.uuid @pages = pages || [] @prefix = [:prefix].to_s @serializer = [:serializer] || ::Airspace::Serializer.new @metadata = ::Airspace::Metadata.new( expires_in_seconds: [:expires_in_seconds], page_count: pages.length, pages_per_chunk: [:pages_per_chunk] ) freeze end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def client @client end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def id @id end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def pages @pages end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def prefix @prefix end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
16 17 18 |
# File 'lib/airspace/dataset.rb', line 16 def serializer @serializer end |
Instance Method Details
#save ⇒ Object
42 43 44 45 46 |
# File 'lib/airspace/dataset.rb', line 42 def save store.persist(key, info_hash, chunks, expires_in_seconds) self end |