Module: Iqvoc::Configuration::Core::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#ability_classObject



174
175
176
# File 'lib/iqvoc/configuration/core.rb', line 174

def ability_class
  ability_class_name.constantize
end

#all_languagesObject

returns a list of all languages selectable for labels and/or notes



187
188
189
190
191
# File 'lib/iqvoc/configuration/core.rb', line 187

def all_languages
  (Iqvoc::Concept.pref_labeling_languages +
      Iqvoc::Concept.further_labeling_class_names.values.flatten +
      note_languages).compact.map(&:to_s).uniq
end

#change_note_classObject



162
163
164
# File 'lib/iqvoc/configuration/core.rb', line 162

def change_note_class
  change_note_class_name.constantize
end

#concept_modal_preview_enabled?Boolean

Returns:

  • (Boolean)


199
200
201
# File 'lib/iqvoc/configuration/core.rb', line 199

def concept_modal_preview_enabled?
  config['concept_modal_preview'] == true
end

#config(&block) ⇒ Object

************** instance configuration **************



153
154
155
156
157
158
159
160
# File 'lib/iqvoc/configuration/core.rb', line 153

def config(&block)
  cfg = Iqvoc::Configuration::InstanceConfiguration.instance
  if block
    block.call(cfg)
  else
    return cfg
  end
end

#engine?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/iqvoc/configuration/core.rb', line 203

def engine?
  Iqvoc.const_defined?(:Engine)
end

#first_level_classesObject



170
171
172
# File 'lib/iqvoc/configuration/core.rb', line 170

def first_level_classes
  self.first_level_class_configuration_modules.map { |mod| mod.send(:base_class) }
end

#host_versionObject



222
223
224
225
226
# File 'lib/iqvoc/configuration/core.rb', line 222

def host_version
  if Iqvoc.host_namespace
    Iqvoc.host_namespace::VERSION
  end
end

#note_languagesObject



182
183
184
# File 'lib/iqvoc/configuration/core.rb', line 182

def note_languages
  config['languages.notes']
end

#rootObject



207
208
209
210
211
212
213
# File 'lib/iqvoc/configuration/core.rb', line 207

def root
  if engine?
    Iqvoc::Engine.root
  else
    Rails.root
  end
end

#routing_constraintObject



215
216
217
218
219
220
# File 'lib/iqvoc/configuration/core.rb', line 215

def routing_constraint
  lambda do |params, req|
    langs = Iqvoc::Concept.pref_labeling_languages.join('|').presence || 'en'
    return params[:lang].to_s =~ /^#{langs}$/
  end
end

#searchable_classesObject



166
167
168
# File 'lib/iqvoc/configuration/core.rb', line 166

def searchable_classes
  searchable_class_names.keys.map(&:constantize)
end

#titleObject



178
179
180
# File 'lib/iqvoc/configuration/core.rb', line 178

def title
  config['title']
end

#title=(value) ⇒ Object

Deprecated.


194
195
196
197
# File 'lib/iqvoc/configuration/core.rb', line 194

def title=(value)
  ActiveSupport::Deprecation.warn 'title has been moved into instance configuration', caller
  self.config.register_setting('title', value)
end