Class: Reap::Project::Defaults
Overview
Project Settings Defaults
Provides an inteface to default values for Settings. The default values are loaded from a .yaml file.
Constant Summary collapse
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(metadata) ⇒ Defaults
constructor
FIXME: when using the settings, I think nil should be considered a none entry and so false would be required to actually mean “off”.
-
#method_missing(s, *a) ⇒ Object
open hash.
Methods included from Extensions::Hash
#argumentize, #to_console, #to_ostruct
Constructor Details
#initialize(metadata) ⇒ Defaults
FIXME: when using the settings, I think nil should be considered a none entry and so false would be required to actually mean “off”. This means assigning each key value par one a time?
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/reap/defaults.rb', line 19 def initialize() super() @metadata = defaults = File.read(DEFAULT_FILE) defaults = instance_eval("<<-XXXXXXXXXXXXX\n#{defaults}\nXXXXXXXXXXXXX") defaults = YAML::load(defaults) #settings = defaults.dup #data.each do |key, value| # settings[key] ||= {} # settings[key].update(value) if value #end update(defaults) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s, *a) ⇒ Object
open hash
35 36 37 38 39 40 41 42 43 |
# File 'lib/reap/defaults.rb', line 35 def method_missing(s, *a) if s =~ /=$/ self[s] = a[0] elsif a.empty? self[s] else super end end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
14 15 16 |
# File 'lib/reap/defaults.rb', line 14 def @metadata end |