Class: Legion::Extensions::Agentic::Homeostasis::Surplus::Helpers::Allocation

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_typeObject (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

#amountObject (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_atObject (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

#idObject (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

#qualityObject (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

Returns:

  • (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_hObject



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