lib/rflow/configuration/setting.rb in rflow-1.3.0 vs lib/rflow/configuration/setting.rb in rflow-1.3.1

- old
+ new

@@ -1,25 +1,28 @@ require 'active_record' require 'rflow/configuration/uuid_keyed' class RFlow class Configuration + # Represents a setting in the SQLite database. class Setting < ConfigurationItem include ActiveModel::Validations self.primary_key = 'name' + # Default settings. DEFAULTS = { 'rflow.application_name' => 'rflow', 'rflow.application_directory_path' => '.', 'rflow.pid_directory_path' => 'run', # relative to rflow.application_directory_path 'rflow.log_directory_path' => 'log', # relative to rflow.application_directory_path 'rflow.log_file_path' => lambda {File.join(Setting['rflow.log_directory_path'], Setting['rflow.application_name'] + '.log')}, 'rflow.pid_file_path' => lambda {File.join(Setting['rflow.pid_directory_path'], Setting['rflow.application_name'] + '.pid')}, 'rflow.log_level' => 'INFO', } + private DIRECTORY_PATHS = [ 'rflow.application_directory_path', 'rflow.pid_directory_path', 'rflow.log_directory_path', ] @@ -50,9 +53,12 @@ unless File.writable? self.value errors.add :value, "setting '#{self.name}' is not writable ('#{File.expand_path self.value}')" end end + public + # Look up a {Setting} by name from the SQLite database. + # @return [Setting] def self.[](name) Setting.find(name).value rescue nil end end end