Class: Bound::HashSeeder

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

Instance Method Summary collapse

Constructor Details

#initialize(receiver) ⇒ HashSeeder

Returns a new instance of HashSeeder.



273
274
275
# File 'lib/bound.rb', line 273

def initialize(receiver)
  @receiver = receiver
end

Instance Method Details

#seed(hash) ⇒ Object



277
278
279
280
281
282
283
284
285
# File 'lib/bound.rb', line 277

def seed(hash)
  hash.each do |key, value|
    attribute = @receiver.get_attribute(key)
    next if attribute && attribute.is_assigned?

    method = "#{key}="
    @receiver.send method, value
  end
end