Module: Iqvoc::Configuration::Concept::ClassMethods

Defined in:
lib/iqvoc/configuration/concept.rb

Instance Method Summary collapse

Instance Method Details

#additional_association_classesObject



149
150
151
152
153
# File 'lib/iqvoc/configuration/concept.rb', line 149

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_classObject



82
83
84
# File 'lib/iqvoc/configuration/concept.rb', line 82

def alt_labeling_class
  alt_labeling_class_name.constantize
end

#base_classObject

Do not use the following method in models. This will probably cause a loading loop (something like “expected file xyz to load …”)



70
71
72
# File 'lib/iqvoc/configuration/concept.rb', line 70

def base_class
  base_class_name.constantize
end

#broader_relation_classObject



94
95
96
# File 'lib/iqvoc/configuration/concept.rb', line 94

def broader_relation_class
  broader_relation_class_name.constantize
end

#further_labeling_class_namesObject

returns hash of class name / languages pairs e.g. { “Labeling::SKOS::AltLabel” => [“de”, “en”] }



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/iqvoc/configuration/concept.rb', line 100

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.


170
171
172
173
174
175
176
# File 'lib/iqvoc/configuration/concept.rb', line 170

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_classesObject



112
113
114
115
116
# File 'lib/iqvoc/configuration/concept.rb', line 112

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_classesObject



126
127
128
# File 'lib/iqvoc/configuration/concept.rb', line 126

def further_relation_classes
  further_relation_class_names.map(&:constantize)
end

#include_modulesObject



159
160
161
# File 'lib/iqvoc/configuration/concept.rb', line 159

def include_modules
  include_module_names.map(&:constantize)
end

#labeling_class_namesObject



86
87
88
# File 'lib/iqvoc/configuration/concept.rb', line 86

def labeling_class_names
  { pref_labeling_class_name => pref_labeling_languages }.merge(further_labeling_class_names)
end

#labeling_classesObject



90
91
92
# File 'lib/iqvoc/configuration/concept.rb', line 90

def labeling_classes
  { pref_labeling_class => pref_labeling_languages }.merge(further_labeling_classes)
end

#match_classesObject



134
135
136
# File 'lib/iqvoc/configuration/concept.rb', line 134

def match_classes
  match_class_names.map(&:constantize)
end

#notation_classesObject



145
146
147
# File 'lib/iqvoc/configuration/concept.rb', line 145

def notation_classes
  notation_class_names.map(&:constantize)
end

#note_classesObject



130
131
132
# File 'lib/iqvoc/configuration/concept.rb', line 130

def note_classes
  note_class_names.map(&:constantize)
end

#pref_labeling_classObject



78
79
80
# File 'lib/iqvoc/configuration/concept.rb', line 78

def pref_labeling_class
  pref_labeling_class_name.constantize
end

#pref_labeling_languagesObject



62
63
64
65
66
# File 'lib/iqvoc/configuration/concept.rb', line 62

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.


164
165
166
167
# File 'lib/iqvoc/configuration/concept.rb', line 164

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_namesObject



118
119
120
# File 'lib/iqvoc/configuration/concept.rb', line 118

def relation_class_names
  further_relation_class_names + [broader_relation_class_name, broader_relation_class.narrower_class.name]
end

#relation_classesObject



122
123
124
# File 'lib/iqvoc/configuration/concept.rb', line 122

def relation_classes
  relation_class_names.map(&:constantize)
end

#reverse_match_class_namesObject



138
139
140
141
142
143
# File 'lib/iqvoc/configuration/concept.rb', line 138

def reverse_match_class_names
  match_class_names.inject({}) do |result, element|
     result[element] = element.parameterize.underscore
     result
  end
end

#root_classObject



74
75
76
# File 'lib/iqvoc/configuration/concept.rb', line 74

def root_class
  root_class_name.constantize
end

#supports_multi_language_pref_labelings?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/iqvoc/configuration/concept.rb', line 155

def supports_multi_language_pref_labelings?
  pref_labeling_languages.size > 1
end