Class: AppCfg::ModelSource

Inherits:
Source
  • Object
show all
Defined in:
lib/appcfg/sources/model_source.rb

Instance Method Summary collapse

Methods inherited from Source

add, list, reload_sources!, #to_hash

Constructor Details

#initialize(options = {}) ⇒ ModelSource

Returns a new instance of ModelSource.



3
4
5
# File 'lib/appcfg/sources/model_source.rb', line 3

def initialize(options = {})
  @model_class = options[:class]
end

Instance Method Details

#reload_data!Object



7
8
9
10
11
12
# File 'lib/appcfg/sources/model_source.rb', line 7

def reload_data!
  @hash = {}
  @model_class.all.each do |instance|
    @hash[instance.key] = instance.value
  end
end