Class: Textus::Envelope
- Inherits:
-
Data
- Object
- Data
- Textus::Envelope
- Defined in:
- lib/textus/envelope.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#freshness ⇒ Object
readonly
Returns the value of attribute freshness.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#schema_ref ⇒ Object
readonly
Returns the value of attribute schema_ref.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Class Method Summary collapse
-
.build(key:, mentry:, path:, meta:, body:, etag:, content: nil, freshness: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- .extract_uid(meta) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def body @body end |
#content ⇒ Object (readonly)
Returns the value of attribute content
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def content @content end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def etag @etag end |
#format ⇒ Object (readonly)
Returns the value of attribute format
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def format @format end |
#freshness ⇒ Object (readonly)
Returns the value of attribute freshness
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def freshness @freshness end |
#key ⇒ Object (readonly)
Returns the value of attribute key
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def key @key end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def @meta end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def path @path end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def protocol @protocol end |
#schema_ref ⇒ Object (readonly)
Returns the value of attribute schema_ref
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def schema_ref @schema_ref end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def uid @uid end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone
4 5 6 |
# File 'lib/textus/envelope.rb', line 4 def zone @zone end |
Class Method Details
.build(key:, mentry:, path:, meta:, body:, etag:, content: nil, freshness: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/textus/envelope.rb', line 9 def self.build(key:, mentry:, path:, meta:, body:, etag:, content: nil, freshness: nil) # rubocop:enable Metrics/ParameterLists new( protocol: Textus::PROTOCOL, key: key, zone: mentry.zone, owner: mentry.owner, path: path, format: mentry.format, uid: extract_uid(), etag: etag, schema_ref: mentry.schema, meta: , body: body, content: content, freshness: freshness, ) end |
.extract_uid(meta) ⇒ Object
28 29 30 31 |
# File 'lib/textus/envelope.rb', line 28 def self.extract_uid() v = .is_a?(Hash) ? ["uid"] : nil v.is_a?(String) ? v : nil end |
Instance Method Details
#refreshing? ⇒ Boolean
56 57 58 |
# File 'lib/textus/envelope.rb', line 56 def refreshing? freshness.is_a?(Hash) && (freshness["refreshing"] == true || freshness[:refreshing] == true) end |
#stale? ⇒ Boolean
52 53 54 |
# File 'lib/textus/envelope.rb', line 52 def stale? freshness.is_a?(Hash) && (freshness["stale"] == true || freshness[:stale] == true) end |
#to_h_for_wire ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/textus/envelope.rb', line 33 def to_h_for_wire h = { "protocol" => protocol, "key" => key, "zone" => zone, "owner" => owner, "path" => path, "format" => format, "_meta" => , "body" => body, "etag" => etag, "schema_ref" => schema_ref, "uid" => uid, } h["content"] = content unless content.nil? freshness.each { |k, v| h[k.to_s] = v } if freshness.is_a?(Hash) h end |