Class: Igniter::Extensions::Contracts::Dataflow::CollectionResult
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Dataflow::CollectionResult
- Includes:
- Enumerable
- Defined in:
- lib/igniter/extensions/contracts/dataflow/collection_result.rb
Instance Attribute Summary collapse
-
#diff ⇒ Object
readonly
Returns the value of attribute diff.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
- #each_value(&block) ⇒ Object
- #fetch(key) ⇒ Object
-
#initialize(items:, diff:) ⇒ CollectionResult
constructor
A new instance of CollectionResult.
- #keys ⇒ Object
- #successes ⇒ Object
- #summary ⇒ Object
- #to_h ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(items:, diff:) ⇒ CollectionResult
Returns a new instance of CollectionResult.
12 13 14 15 16 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 12 def initialize(items:, diff:) @items = items.dup.freeze @diff = diff freeze end |
Instance Attribute Details
#diff ⇒ Object (readonly)
Returns the value of attribute diff.
10 11 12 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 10 def diff @diff end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
10 11 12 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 10 def items @items end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 18 def [](key) items[key] end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 26 def each(&block) items.each(&block) end |
#each_value(&block) ⇒ Object
30 31 32 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 30 def each_value(&block) items.each_value(&block) end |
#fetch(key) ⇒ Object
22 23 24 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 22 def fetch(key) items.fetch(key) end |
#keys ⇒ Object
34 35 36 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 34 def keys items.keys end |
#successes ⇒ Object
42 43 44 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 42 def successes items end |
#summary ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 46 def summary { mode: :incremental, total: items.size, succeeded: items.size, failed: 0, status: :success, added: diff.added.size, removed: diff.removed.size, changed: diff.changed.size, unchanged: diff.unchanged.size } end |
#to_h ⇒ Object
60 61 62 63 64 65 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 60 def to_h { items: items.transform_values(&:to_h), diff: diff.to_h } end |
#values ⇒ Object
38 39 40 |
# File 'lib/igniter/extensions/contracts/dataflow/collection_result.rb', line 38 def values items.values end |