-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: code refactored and unused code removed
- Loading branch information
1 parent
2ef5bb6
commit 8a8a4c0
Showing
15 changed files
with
372 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module Glossarist | ||
class ConceptData < Lutaml::Model::Serializable | ||
include Glossarist::Utilities::CommonFunctions | ||
|
||
attribute :dates, ConceptDate, collection: true | ||
attribute :definition, DetailedDefinition, collection: true | ||
attribute :examples, DetailedDefinition, collection: true | ||
attribute :id, :string | ||
attribute :lineage_source_similarity, :integer | ||
attribute :notes, DetailedDefinition, collection: true | ||
attribute :release, :string | ||
attribute :sources, ConceptSource, collection: true | ||
attribute :terms, Designation::Base, collection: true | ||
attribute :related, RelatedConcept, collection: true | ||
attribute :domain, :string | ||
|
||
# Concept Methods | ||
# Language code should be exactly 3 char long. | ||
# TODO: use min_length, max_length once added in lutaml-model | ||
attribute :language_code, :string, pattern: /^.{3}$/ | ||
attribute :entry_status, :string | ||
|
||
yaml do | ||
map :dates, to: :dates | ||
map :definition, to: :definition, render_nil: true | ||
map :examples, to: :examples, render_nil: true | ||
map :id, to: :id | ||
map :lineage_source_similarity, to: :lineage_source_similarity | ||
map :notes, to: :notes, render_nil: true | ||
map :release, to: :release | ||
map :sources, to: :sources | ||
map :terms, to: :terms, with: { from: :terms_from_hash, to: :terms_to_hash } | ||
map :related, to: :related | ||
map :domain, to: :domain | ||
map :language_code, to: :language_code | ||
map :entry_status, to: :entry_status | ||
end | ||
|
||
def terms_from_hash(model, value) | ||
model.terms = value.map { |v| Designation::Base.of_yaml(v) } | ||
end | ||
|
||
def terms_to_hash(model, doc) | ||
doc["terms"] = model.terms.map(&:to_yaml_hash) | ||
end | ||
|
||
def date_accepted | ||
return nil unless dates | ||
|
||
dates.find { |date| date.accepted? } | ||
end | ||
|
||
def authoritative_source | ||
return [] unless sources | ||
|
||
sources.select { |source| source.authoritative? } | ||
end | ||
end | ||
end |
Oops, something went wrong.