module ActsAsPreferenced # This class only helps with defining of preference sections, not with storage # (as I see no reason to make storage more complicated while bringing no real # benefit) class Section # Options: # * prefix - if true, section name will be prepended to all preferences # defined within. False by default def initialize( store, name, options = {} ) options.assert_valid_keys( :prefix ) @store, @name = store, name @prefix = options[:prefix] end def preference( name, options = {} ) pref_name = (@prefix ? "#{@name}_#{name}".to_sym : name) @store.preference( pref_name, options.merge( :section => @name )) end end end