Sha256: 5c7e546960e2c8a7dc2bebc928fec171560136a918988ca4be030d9152ce5692
Contents?: true
Size: 1.32 KB
Versions: 11
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Glossarist class ConceptSource < Model include Glossarist::Utilities::Enum include Glossarist::Utilities::CommonFunctions register_enum :status, Glossarist::GlossaryDefinition::CONCEPT_SOURCE_STATUSES register_enum :type, Glossarist::GlossaryDefinition::CONCEPT_SOURCE_TYPES attr_reader :origin alias_method :ref, :origin attr_accessor :modification 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 def origin=(origin) @origin = Citation.new(origin) end alias_method :ref=, :origin= 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 private def ref_param_names %w[ ref text source id version clause link original ] end end end
Version data entries
11 entries across 11 versions & 2 rubygems