Module: Iqvoc::Configuration::Concept::ClassMethods
- Defined in:
- lib/iqvoc/configuration/concept.rb
Instance Method Summary collapse
- #additional_association_classes ⇒ Object
- #alt_labeling_class ⇒ Object
-
#base_class ⇒ Object
Do not use the following method in models.
- #broader_relation_class ⇒ Object
-
#further_labeling_class_names ⇒ Object
returns hash of class name / languages pairs e.g.
- #further_labeling_class_names=(hsh) ⇒ Object deprecated Deprecated.
- #further_labeling_classes ⇒ Object
- #further_relation_classes ⇒ Object
- #include_modules ⇒ Object
- #labeling_class_names ⇒ Object
- #labeling_classes ⇒ Object
- #match_classes ⇒ Object
- #notation_classes ⇒ Object
- #note_classes ⇒ Object
- #pref_labeling_class ⇒ Object
- #pref_labeling_languages ⇒ Object
- #pref_labeling_languages=(value) ⇒ Object deprecated Deprecated.
- #relation_class_names ⇒ Object
- #relation_classes ⇒ Object
- #reverse_match_class_names ⇒ Object
- #root_class ⇒ Object
- #supports_multi_language_pref_labelings? ⇒ Boolean
Instance Method Details
#additional_association_classes ⇒ Object
147 148 149 150 151 |
# File 'lib/iqvoc/configuration/concept.rb', line 147 def additional_association_classes additional_association_class_names.keys.each_with_object({}) do |class_name, hash| hash[class_name.constantize] = additional_association_class_names[class_name] end end |
#alt_labeling_class ⇒ Object
80 81 82 |
# File 'lib/iqvoc/configuration/concept.rb', line 80 def alt_labeling_class alt_labeling_class_name.constantize end |
#base_class ⇒ Object
Do not use the following method in models. This will probably cause a loading loop (something like “expected file xyz to load …”)
68 69 70 |
# File 'lib/iqvoc/configuration/concept.rb', line 68 def base_class base_class_name.constantize end |
#broader_relation_class ⇒ Object
92 93 94 |
# File 'lib/iqvoc/configuration/concept.rb', line 92 def broader_relation_class broader_relation_class_name.constantize end |
#further_labeling_class_names ⇒ Object
returns hash of class name / languages pairs e.g. { “Labeling::SKOS::AltLabel” => [“de”, “en”] }
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/iqvoc/configuration/concept.rb', line 98 def further_labeling_class_names # FIXME: mutable object; needs custom hash setters to guard against # modification of languages arrays (to highlight deprecated usage) return Iqvoc.config.defaults.each_with_object({}) do |(key, default_value), hsh| prefix = 'languages.further_labelings.' if key.start_with? prefix class_name = key[prefix.length..-1] hsh[class_name] = Iqvoc.config[key] end end end |
#further_labeling_class_names=(hsh) ⇒ Object
Deprecated.
168 169 170 171 172 173 174 |
# File 'lib/iqvoc/configuration/concept.rb', line 168 def further_labeling_class_names=(hsh) ActiveSupport::Deprecation.warn 'further_labeling_class_names has been moved into instance configuration', caller prefix = 'languages.further_labelings.' hsh.each do |class_name, value| Iqvoc.config.register_setting(prefix + class_name, value.map(&:to_s)) end end |
#further_labeling_classes ⇒ Object
110 111 112 113 114 |
# File 'lib/iqvoc/configuration/concept.rb', line 110 def further_labeling_classes further_labeling_class_names.keys.each_with_object({}) do |class_name, hash| hash[class_name.constantize] = further_labeling_class_names[class_name] end end |
#further_relation_classes ⇒ Object
124 125 126 |
# File 'lib/iqvoc/configuration/concept.rb', line 124 def further_relation_classes further_relation_class_names.map(&:constantize) end |
#include_modules ⇒ Object
157 158 159 |
# File 'lib/iqvoc/configuration/concept.rb', line 157 def include_modules include_module_names.map(&:constantize) end |
#labeling_class_names ⇒ Object
84 85 86 |
# File 'lib/iqvoc/configuration/concept.rb', line 84 def labeling_class_names { pref_labeling_class_name => pref_labeling_languages }.merge(further_labeling_class_names) end |
#labeling_classes ⇒ Object
88 89 90 |
# File 'lib/iqvoc/configuration/concept.rb', line 88 def labeling_classes { pref_labeling_class => pref_labeling_languages }.merge(further_labeling_classes) end |
#match_classes ⇒ Object
132 133 134 |
# File 'lib/iqvoc/configuration/concept.rb', line 132 def match_classes match_class_names.map(&:constantize) end |
#notation_classes ⇒ Object
143 144 145 |
# File 'lib/iqvoc/configuration/concept.rb', line 143 def notation_classes notation_class_names.map(&:constantize) end |
#note_classes ⇒ Object
128 129 130 |
# File 'lib/iqvoc/configuration/concept.rb', line 128 def note_classes note_class_names.map(&:constantize) end |
#pref_labeling_class ⇒ Object
76 77 78 |
# File 'lib/iqvoc/configuration/concept.rb', line 76 def pref_labeling_class pref_labeling_class_name.constantize end |
#pref_labeling_languages ⇒ Object
60 61 62 63 64 |
# File 'lib/iqvoc/configuration/concept.rb', line 60 def pref_labeling_languages # FIXME: mutable object; needs custom array setters to guard against # modification (to highlight deprecated usage) return Iqvoc.config['languages.pref_labeling'] end |
#pref_labeling_languages=(value) ⇒ Object
Deprecated.
162 163 164 165 |
# File 'lib/iqvoc/configuration/concept.rb', line 162 def pref_labeling_languages=(value) ActiveSupport::Deprecation.warn 'pref_labeling_languages has been moved into instance configuration', caller Iqvoc.config.register_setting('languages.pref_labeling', value) end |
#relation_class_names ⇒ Object
116 117 118 |
# File 'lib/iqvoc/configuration/concept.rb', line 116 def relation_class_names further_relation_class_names + [broader_relation_class_name, broader_relation_class.narrower_class.name] end |
#relation_classes ⇒ Object
120 121 122 |
# File 'lib/iqvoc/configuration/concept.rb', line 120 def relation_classes relation_class_names.map(&:constantize) end |
#reverse_match_class_names ⇒ Object
136 137 138 139 140 141 |
# File 'lib/iqvoc/configuration/concept.rb', line 136 def reverse_match_class_names match_class_names.inject({}) do |result, element| result[element] = element.parameterize.underscore result end end |
#root_class ⇒ Object
72 73 74 |
# File 'lib/iqvoc/configuration/concept.rb', line 72 def root_class root_class_name.constantize end |
#supports_multi_language_pref_labelings? ⇒ Boolean
153 154 155 |
# File 'lib/iqvoc/configuration/concept.rb', line 153 def supports_multi_language_pref_labelings? pref_labeling_languages.size > 1 end |