class AMEE::Db::BaseConfig
A singleton class for configuration. Automatically initialised on first use Use like so:
AMEE::Db::Config.instance.store_everything?
Separated into BaseConfig
and Config
to allow unit testing of singleton.
Attributes
storage_method[R]
Public Class Methods
new()
click to toggle source
# File lib/amee/db/config.rb, line 20 def initialize # Default is metadata @storage_method = load_storage_method || :metadata end
Public Instance Methods
store_everything?()
click to toggle source
# File lib/amee/db/config.rb, line 35 def store_everything? [:everything].include? storage_method end
store_metadata?()
click to toggle source
# File lib/amee/db/config.rb, line 27 def store_metadata? [:metadata, :outputs, :everything].include? storage_method end
store_outputs?()
click to toggle source
# File lib/amee/db/config.rb, line 31 def store_outputs? [:outputs, :everything].include? storage_method end
Private Instance Methods
load_storage_method()
click to toggle source
# File lib/amee/db/config.rb, line 41 def load_storage_method m = YAML.load_file("#{::Rails.root}/config/persistence.yml")['method'].to_sym raise "amee-data-persistence: Invalid storage method" unless [:metadata, :outputs, :everything].include? m m end