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

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

Instance Method Summary collapse

Instance Method Details

#ability_classObject



143
144
145
# File 'lib/iqvoc/configuration/core.rb', line 143

def ability_class
  ability_class_name.constantize
end

#available_languagesObject



151
152
153
# File 'lib/iqvoc/configuration/core.rb', line 151

def available_languages
  return config["available_languages"]
end

#available_languages=(value) ⇒ Object

Deprecated.


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

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

#change_note_classObject



131
132
133
# File 'lib/iqvoc/configuration/core.rb', line 131

def change_note_class
  change_note_class_name.constantize
end

#config(&block) ⇒ Object

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



122
123
124
125
126
127
128
129
# File 'lib/iqvoc/configuration/core.rb', line 122

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

#first_level_classesObject



139
140
141
# File 'lib/iqvoc/configuration/core.rb', line 139

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

#generate_secret_tokenObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/iqvoc/configuration/core.rb', line 101

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

#searchable_classesObject



135
136
137
# File 'lib/iqvoc/configuration/core.rb', line 135

def searchable_classes
  searchable_class_names.map(&:constantize)
end

#titleObject



147
148
149
# File 'lib/iqvoc/configuration/core.rb', line 147

def title
  return config["title"]
end

#title=(value) ⇒ Object

Deprecated.


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

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