Class: Reap::Project::Defaults

Inherits:
Hash
  • Object
show all
Defined in:
lib/reap/defaults.rb

Overview

Project Settings Defaults

Provides an inteface to default values for Settings. The default values are loaded from a .yaml file.

Constant Summary collapse

DEFAULT_FILE =
File.join(File.dirname(__FILE__), 'default.yaml')

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#metadataObject (readonly)

Returns the value of attribute metadata.



14
15
16
# File 'lib/reap/defaults.rb', line 14

def 
  @metadata
end