Class: Igniter::Contracts::Execution::Operation
- Inherits:
-
Object
- Object
- Igniter::Contracts::Execution::Operation
- Defined in:
- lib/igniter/contracts/execution/operation.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #attribute(key) ⇒ Object
- #attribute?(key) ⇒ Boolean
-
#initialize(kind:, name:, attributes: {}) ⇒ Operation
constructor
A new instance of Operation.
- #output? ⇒ Boolean
- #to_h ⇒ Object
- #with_attributes(updated_attributes) ⇒ Object
Constructor Details
#initialize(kind:, name:, attributes: {}) ⇒ Operation
Returns a new instance of Operation.
9 10 11 12 13 14 |
# File 'lib/igniter/contracts/execution/operation.rb', line 9 def initialize(kind:, name:, attributes: {}) @kind = kind.to_sym @name = name.to_sym @attributes = attributes.transform_keys(&:to_sym).freeze freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/igniter/contracts/execution/operation.rb', line 7 def attributes @attributes end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
7 8 9 |
# File 'lib/igniter/contracts/execution/operation.rb', line 7 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/igniter/contracts/execution/operation.rb', line 7 def name @name end |
Instance Method Details
#attribute(key) ⇒ Object
16 17 18 |
# File 'lib/igniter/contracts/execution/operation.rb', line 16 def attribute(key) attributes.fetch(key.to_sym) end |
#attribute?(key) ⇒ Boolean
20 21 22 |
# File 'lib/igniter/contracts/execution/operation.rb', line 20 def attribute?(key) attributes.key?(key.to_sym) end |
#output? ⇒ Boolean
28 29 30 |
# File 'lib/igniter/contracts/execution/operation.rb', line 28 def output? kind == :output end |
#to_h ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/igniter/contracts/execution/operation.rb', line 32 def to_h { kind: kind, name: name, attributes: StructuredDump.dump(attributes) } end |
#with_attributes(updated_attributes) ⇒ Object
24 25 26 |
# File 'lib/igniter/contracts/execution/operation.rb', line 24 def with_attributes(updated_attributes) self.class.new(kind: kind, name: name, attributes: updated_attributes) end |