Class: Igniter::Store::Protocol::Receipt
- Inherits:
-
Struct
- Object
- Struct
- Igniter::Store::Protocol::Receipt
- Defined in:
- lib/igniter/store/protocol/receipt.rb
Instance Attribute Summary collapse
-
#derived ⇒ Object
Returns the value of attribute derived.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#fact_id ⇒ Object
Returns the value of attribute fact_id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#name ⇒ Object
Returns the value of attribute name.
-
#schema_version ⇒ Object
Returns the value of attribute schema_version.
-
#status ⇒ Object
Returns the value of attribute status.
-
#store ⇒ Object
Returns the value of attribute store.
-
#value_hash ⇒ Object
Returns the value of attribute value_hash.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Class Method Summary collapse
- .accepted(kind:, name:, warnings: [], derived: []) ⇒ Object
- .append_accepted(history:, fact:, requested_key: nil) ⇒ Object
- .deduplicated(kind:, name:) ⇒ Object
- .rejection(message, kind: nil, name: nil) ⇒ Object
- .write_accepted(store:, key:, fact:) ⇒ Object
Instance Method Summary collapse
- #accepted? ⇒ Boolean
- #deduplicated? ⇒ Boolean
- #rejected? ⇒ Boolean
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Instance Attribute Details
#derived ⇒ Object
Returns the value of attribute derived
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def derived @derived end |
#errors ⇒ Object
Returns the value of attribute errors
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def errors @errors end |
#fact_id ⇒ Object
Returns the value of attribute fact_id
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def fact_id @fact_id end |
#key ⇒ Object
Returns the value of attribute key
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def key @key end |
#kind ⇒ Object
Returns the value of attribute kind
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def kind @kind end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def name @name end |
#schema_version ⇒ Object
Returns the value of attribute schema_version
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def schema_version @schema_version end |
#status ⇒ Object
Returns the value of attribute status
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def status @status end |
#store ⇒ Object
Returns the value of attribute store
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def store @store end |
#value_hash ⇒ Object
Returns the value of attribute value_hash
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def value_hash @value_hash end |
#warnings ⇒ Object
Returns the value of attribute warnings
6 7 8 |
# File 'lib/igniter/store/protocol/receipt.rb', line 6 def warnings @warnings end |
Class Method Details
.accepted(kind:, name:, warnings: [], derived: []) ⇒ Object
24 25 26 27 |
# File 'lib/igniter/store/protocol/receipt.rb', line 24 def self.accepted(kind:, name:, warnings: [], derived: []) new(schema_version: 1, kind: kind, status: :accepted, name: name, warnings: warnings, errors: [], derived: derived) end |
.append_accepted(history:, fact:, requested_key: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/igniter/store/protocol/receipt.rb', line 54 def self.append_accepted(history:, fact:, requested_key: nil) warnings = [] if requested_key && requested_key.to_s != fact.key.to_s warnings << "append key is metadata only in protocol v0; generated fact key returned" end new( schema_version: 1, kind: :append_receipt, status: :accepted, store: history, key: fact.key, fact_id: fact.id, value_hash: fact.value_hash, warnings: warnings, errors: [], derived: [] ) end |
.deduplicated(kind:, name:) ⇒ Object
34 35 36 37 |
# File 'lib/igniter/store/protocol/receipt.rb', line 34 def self.deduplicated(kind:, name:) new(schema_version: 1, kind: kind, status: :deduplicated, name: name, warnings: ["descriptor already registered"], errors: [], derived: []) end |
.rejection(message, kind: nil, name: nil) ⇒ Object
29 30 31 32 |
# File 'lib/igniter/store/protocol/receipt.rb', line 29 def self.rejection(, kind: nil, name: nil) new(schema_version: 1, kind: kind, status: :rejected, name: name, warnings: [], errors: [], derived: []) end |
.write_accepted(store:, key:, fact:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/igniter/store/protocol/receipt.rb', line 39 def self.write_accepted(store:, key:, fact:) new( schema_version: 1, kind: :receipt, status: :accepted, store: store, key: key, fact_id: fact.id, value_hash: fact.value_hash, warnings: [], errors: [], derived: [] ) end |
Instance Method Details
#accepted? ⇒ Boolean
20 |
# File 'lib/igniter/store/protocol/receipt.rb', line 20 def accepted? = status == :accepted |
#deduplicated? ⇒ Boolean
22 |
# File 'lib/igniter/store/protocol/receipt.rb', line 22 def deduplicated? = status == :deduplicated |
#rejected? ⇒ Boolean
21 |
# File 'lib/igniter/store/protocol/receipt.rb', line 21 def rejected? = status == :rejected |
#to_h ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/igniter/store/protocol/receipt.rb', line 74 def to_h { schema_version: schema_version, kind: kind, status: status, name: name, store: store, key: key, fact_id: fact_id, value_hash: value_hash, warnings: warnings, errors: errors, derived: derived }.compact end |
#to_json(*args) ⇒ Object
90 91 92 |
# File 'lib/igniter/store/protocol/receipt.rb', line 90 def to_json(*args) to_h.to_json(*args) end |