From: Brian Candler Date: 2012-06-06T02:12:54+09:00 Subject: Re: appropriate use of constants > I'd probably do something like this: ... > # getters and setters > DEFAULT_SETTINGS.each_key do |config_key| > define_method config_key do > DEFAULT_SETTINGS[config_key] > end > define_method "#{config_key}=" do |val| > DEFAULT_SETTINGS[config_key] = val > end > end I think you mean @settings, not DEFAULT_SETTINGS? Also I would be inclined to do @settings = DEFAULT_SETTINGS.dup and to freeze DEFAULT_SETTINGS But it may be simpler to do: begin Settings = YAML.load("") rescue # Set defaults Settings = {"foo"=>123, "bar"=>456} end If you want the accessor methods, you could use an OpenStruct, or this: https://github.com/candlerb/couchtiny/blob/master/lib/jsobject.rb -- Posted via http://www.ruby-forum.com/.