Class: Qbrick::Settings

Inherits:
RailsSettings::CachedSettings
  • Object
show all
Defined in:
app/models/qbrick/settings.rb

Class Method Summary collapse

Class Method Details

.all_object_hash(starting_with = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/qbrick/settings.rb', line 14

def all_object_hash(starting_with = nil)
  vars = thing_scoped.ordered
  vars = vars.where "var LIKE '#{starting_with}%'" if starting_with

  Hash[vars.map { |record| [record.var, record] }].with_indifferent_access.tap do |result|
    @@defaults.slice(*(@@defaults.keys - result.keys)).each do |key, value|
      next if starting_with.present? && !key.start_with?(starting_with)

      result[key] = Qbrick::Settings.new var: key, value: value
    end
  end
end

.varsObject Also known as: keys



9
10
11
# File 'app/models/qbrick/settings.rb', line 9

def vars
  pluck :var
end