Class: Settings::SettingCollection

Inherits:
Hash show all
Defined in:
lib/more/facets/settings.rb

Overview

A collection of Settings. This helper enables intuitive settings initialization like this:

Settings.Compiler.template_root = ‘public’ instead of Settings.setting :compiler, :template_root, :value => ‘public’

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#&, #*, #+, #-, #<<, #alias!, #argumentize, autonew, #delete_unless, #delete_values, #delete_values_at, #diff, #each_with_key, #except, #except!, #has_keys?, #has_only_keys?, #insert, #inverse, #join, #mash!, #normalize_keys, #normalize_keys!, #pairs_at, #rand_key, #rand_key!, #rand_pair, #rand_pair!, #rand_value, #rand_value!, #rekey, #rekey!, #replace_each, #restore_snapshot, #reverse_merge, #reverse_merge!, #select!, #shuffle, #shuffle!, #slice, #slice!, #stringify_keys, #stringify_keys!, #swap!, #swapkey!, #symbolize_keys, #symbolize_keys!, #take_snapshot, #to_console, #to_h, #to_openobject, #to_ostruct, #to_ostruct_recurse, #to_proc, #to_proc_with_reponse, #to_struct, #traverse, #traverse!, #update_each, #update_keys, #update_values, #variablize_keys, #variablize_keys!, #weave, zipnew, #|

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object

Handles setting readers and writers.



118
119
120
121
122
123
124
125
126
# File 'lib/more/facets/settings.rb', line 118

def method_missing(sym, *args)
  if sym.to_s =~ /=$/
    # Remove trailing
    sym = sym.to_s.gsub(/=/, '').to_sym
    Settings.setting @owner, sym, :value => args.first
  else
    self[sym]
  end
end

Instance Attribute Details

#ownerObject

Returns the value of attribute owner.



114
115
116
# File 'lib/more/facets/settings.rb', line 114

def owner
  @owner
end