Module: Iqvoc::Configuration::Core::ClassMethods
- Defined in:
- lib/iqvoc/configuration/core.rb
Instance Method Summary collapse
- #ability_class ⇒ Object
-
#all_languages ⇒ Object
returns a list of all languages selectable for labels and/or notes.
- #change_note_class ⇒ Object
-
#config(&block) ⇒ Object
************** instance configuration **************.
- #first_level_classes ⇒ Object
- #generate_secret_token ⇒ Object
- #note_languages ⇒ Object
- #root ⇒ Object
- #searchable_classes ⇒ Object
- #title ⇒ Object
- #title=(value) ⇒ Object deprecated Deprecated.
Instance Method Details
#ability_class ⇒ Object
187 188 189 |
# File 'lib/iqvoc/configuration/core.rb', line 187 def ability_class ability_class_name.constantize end |
#all_languages ⇒ Object
returns a list of all languages selectable for labels and/or notes
200 201 202 203 204 |
# File 'lib/iqvoc/configuration/core.rb', line 200 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_class ⇒ Object
175 176 177 |
# File 'lib/iqvoc/configuration/core.rb', line 175 def change_note_class change_note_class_name.constantize end |
#config(&block) ⇒ Object
************** instance configuration **************
166 167 168 169 170 171 172 173 |
# File 'lib/iqvoc/configuration/core.rb', line 166 def config(&block) cfg = InstanceConfiguration.instance if block block.call(cfg) else return cfg end end |
#first_level_classes ⇒ Object
183 184 185 |
# File 'lib/iqvoc/configuration/core.rb', line 183 def first_level_classes self.first_level_class_configuration_modules.map { |mod| mod.send(:base_class) } end |
#generate_secret_token ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/iqvoc/configuration/core.rb', line 145 def generate_secret_token require 'securerandom' template = Rails.root.join("config", "initializers", "secret_token.rb.template") raise "File not found: #{template}" unless File.exist?(template) file_name = "config/initializers/secret_token.rb" token = SecureRandom.hex(64) txt = File.read(template) txt.gsub!("S-E-C-R-E-T", token) File.open(file_name, "w") do |f| f.write txt end puts "Secret token configuration has been created in #{file_name}." end |
#note_languages ⇒ Object
195 196 197 |
# File 'lib/iqvoc/configuration/core.rb', line 195 def note_languages config["languages.notes"] end |
#root ⇒ Object
212 213 214 215 216 217 218 |
# File 'lib/iqvoc/configuration/core.rb', line 212 def root if Iqvoc.const_defined?(:Engine) Iqvoc::Engine.root else Rails.root end end |
#searchable_classes ⇒ Object
179 180 181 |
# File 'lib/iqvoc/configuration/core.rb', line 179 def searchable_classes searchable_class_names.keys.map(&:constantize) end |
#title ⇒ Object
191 192 193 |
# File 'lib/iqvoc/configuration/core.rb', line 191 def title config["title"] end |
#title=(value) ⇒ Object
Deprecated.
207 208 209 210 |
# File 'lib/iqvoc/configuration/core.rb', line 207 def title=(value) ActiveSupport::Deprecation.warn "title has been moved into instance configuration", caller self.config.register_setting("title", value) end |