Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gardener.rb

Class Method Summary collapse

Class Method Details

.yaml_new(klass, tag, val) ⇒ Object



177
178
179
180
181
182
183
184
185
186
# File 'lib/gardener.rb', line 177

def self.yaml_new(klass, tag, val)
  foo = klass.find(val['attributes']['id'])
rescue ActiveRecord::RecordNotFound
  foo = klass.new
  val['attributes'].each do |k, v|
    meth = "#{k}="
    foo.send(meth, v) if foo.respond_to?(meth)
  end
  foo
end