Class: DecisionAgent::Dmn::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/dmn/model.rb

Overview

Root DMN model containing all decisions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, namespace: "http://decision_agent.local") ⇒ Model

Returns a new instance of Model.



11
12
13
14
15
16
# File 'lib/decision_agent/dmn/model.rb', line 11

def initialize(id:, name:, namespace: "http://decision_agent.local")
  @id = id.to_s
  @name = name.to_s
  @namespace = namespace.to_s
  @decisions = []
end

Instance Attribute Details

#decisionsObject (readonly)

Returns the value of attribute decisions.



9
10
11
# File 'lib/decision_agent/dmn/model.rb', line 9

def decisions
  @decisions
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/decision_agent/dmn/model.rb', line 9

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/decision_agent/dmn/model.rb', line 9

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



9
10
11
# File 'lib/decision_agent/dmn/model.rb', line 9

def namespace
  @namespace
end

Instance Method Details

#add_decision(decision) ⇒ Object

Raises:

  • (TypeError)


18
19
20
21
22
# File 'lib/decision_agent/dmn/model.rb', line 18

def add_decision(decision)
  raise TypeError, "Expected Decision, got #{decision.class}" unless decision.is_a?(Decision)

  @decisions << decision
end

#find_decision(decision_id) ⇒ Object



24
25
26
# File 'lib/decision_agent/dmn/model.rb', line 24

def find_decision(decision_id)
  @decisions.find { |d| d.id == decision_id.to_s }
end

#freezeObject



28
29
30
31
32
33
34
35
# File 'lib/decision_agent/dmn/model.rb', line 28

def freeze
  @id.freeze
  @name.freeze
  @namespace.freeze
  @decisions.each(&:freeze)
  @decisions.freeze
  super
end