Class: Legion::Extensions::Agentic::Homeostasis::Surplus::Helpers::Allocation
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Homeostasis::Surplus::Helpers::Allocation
- Defined in:
- lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb
Instance Attribute Summary collapse
-
#activity_type ⇒ Object
readonly
Returns the value of attribute activity_type.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(activity_type:, amount:, quality:) ⇒ Allocation
constructor
A new instance of Allocation.
- #release! ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(activity_type:, amount:, quality:) ⇒ Allocation
Returns a new instance of Allocation.
14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 14 def initialize(activity_type:, amount:, quality:) @id = SecureRandom.uuid @activity_type = activity_type @amount = amount.round(10) @quality = quality.round(10) @created_at = Time.now.utc @released = false end |
Instance Attribute Details
#activity_type ⇒ Object (readonly)
Returns the value of attribute activity_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 12 def activity_type @activity_type end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
12 13 14 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 12 def amount @amount end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 12 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 12 def id @id end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
12 13 14 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 12 def quality @quality end |
Instance Method Details
#active? ⇒ Boolean
27 28 29 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 27 def active? !@released end |
#release! ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 23 def release! @released = true end |
#to_h ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb', line 31 def to_h { id: @id, activity_type: @activity_type, amount: @amount, quality: @quality, active: active?, created_at: @created_at } end |