Robert K. wrote in post #992088:
>
> Choose to your liking. :-)
>

Hey Robert K,

I read your factory pattern thread the other day, and I wonder if that 
pattern would apply here?  After all, producing several anonymous 
instances of Class is akin to producing instances of various classes. 
Something like this:

class ClassFactory
  def self.using(hash)
    Class.new do
     @options = hash

       class << self
         attr_reader :options
       end

     end
  end
end

foo = Opportunities.using({one: 1, two: 2, three: 3})
bar = Opportunities.using({four: 4, five: 5, six: 6})

p foo.options
p bar.options

--output:--
{:one=>1, :two=>2, :three=>3}
{:four=>4, :five=>5, :six=>6}


Hey Lars Olsson,

Check out the shorter syntax for hashes when your keys are symbols.



foo = Opportunities.using({one: 1, two: 2, three: 3})
bar = Opportunities.using({four: 4, five: 5, six: 6})

p foo.options
p bar.options

-- 
Posted via http://www.ruby-forum.com/.