Ruby Class Initialize with attributes
class Hoe
# attr_accessor
def initialize(attributes = nil)
assign_attributes(attributes) if attributes
yield self if block_given?
end
def assign_attributes(new_attributes)
new_attributes.each do |k, v|
send("#{k.to_s}=", v) if respond_to?("#{k.to_s}=")
end
end
end