Forum: Ruby on Rails Version of Struct for initializing via Hash

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
525128e48ca2b4c7fb6176ea166fccfd?d=identicon&s=25 Eric G. (gotskill10)
on 2009-03-16 21:57
is there any equivalent to this

class A

attr_accessor :foo, :bar

def initialize(options={})
options.each{|k,v| send("#{k}=", v)}


I know that OpenStruct is very similar, but you don't get to define
specific attributes.
This topic is locked and can not be replied to.