You are organizing your options as a set, but if you are interested in a
hash model, you might be interested in a “class_superhash”, which is
sort of a hash that inherits key-value pairs according to the class
hierarchy. F’rexample:
require ‘superhash’
class A
class_superhash :options
options[:foo] = 1
def options; self.class.options; end
end
class B < A
options[:bar] = 2
end
p A.options
p B.options.to_hash
p B.new.options.to_hash
Output:
{:foo=>1}
{:foo=>1, :bar=>2}
{:foo=>1, :bar=>2}
The underlying superhash objects support the same interface as a hash.
(This is in my superhash package on RAA.)