Class: Dina::AgentRole

Inherits:
Object
  • Object
show all
Defined in:
lib/dina/components/agent_role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAgentRole

Returns a new instance of AgentRole.



8
9
10
11
# File 'lib/dina/components/agent_role.rb', line 8

def initialize
  @agent = []
  @roles = []
end

Instance Attribute Details

#agentObject

An array of known UUIDs for a Person



3
4
5
# File 'lib/dina/components/agent_role.rb', line 3

def agent
  @agent
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/dina/components/agent_role.rb', line 5

def date
  @date
end

#remarksObject

Returns the value of attribute remarks.



6
7
8
# File 'lib/dina/components/agent_role.rb', line 6

def remarks
  @remarks
end

#rolesObject

An array of roles: Owner, Borrower, Prepared By



4
5
6
# File 'lib/dina/components/agent_role.rb', line 4

def roles
  @roles
end

Instance Method Details

#add_agent(id:) ⇒ Object



13
14
15
16
# File 'lib/dina/components/agent_role.rb', line 13

def add_agent(id:)
  raise PropertyValueInvalid, "Agent must be a UUID." if !id.is_uuid?
  @agent << id
end

#add_role(role:) ⇒ Object



18
19
20
# File 'lib/dina/components/agent_role.rb', line 18

def add_role(role:)
  @roles << role
end

#to_hashObject



22
23
24
25
26
# File 'lib/dina/components/agent_role.rb', line 22

def to_hash
  hash = {}
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
  hash.deep_symbolize_keys
end