Class: Glossarist::ConceptSource

Inherits:
Model
  • Object
show all
Includes:
Utilities::CommonFunctions, Utilities::Enum
Defined in:
lib/glossarist/concept_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities::CommonFunctions

#slice_keys, #symbolize_keys

Methods included from Utilities::Enum

extended, included

Methods inherited from Model

from_h, new, #set_attribute

Constructor Details

#initialize(attributes = {}) ⇒ ConceptSource

Returns a new instance of ConceptSource.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/glossarist/concept_source.rb', line 16

def initialize(attributes = {})
  if rel = attributes.delete("relationship")
    self.status = rel["type"]
    self.modification = rel["modification"]
  end

  self.origin = slice_keys(attributes, ref_param_names)

  remaining_attributes = attributes.dup
  ref_param_names.each { |k| remaining_attributes.delete(k) }

  super(remaining_attributes)
end

Instance Attribute Details

#modificationObject

Returns the value of attribute modification.



14
15
16
# File 'lib/glossarist/concept_source.rb', line 14

def modification
  @modification
end

#originObject Also known as: ref

Returns the value of attribute origin.



11
12
13
# File 'lib/glossarist/concept_source.rb', line 11

def origin
  @origin
end

Instance Method Details

#to_hObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/glossarist/concept_source.rb', line 36

def to_h
  origin_hash = self.origin.to_h.empty? ? nil : self.origin.to_h

  {
    "type" => type.to_s,
    "status" => status&.to_s,
    "origin" => origin_hash,
    "modification" => modification,
  }.compact
end