Module: Dialers::AssignAttributes

Defined in:
lib/dialers/assign_attributes.rb

Class Method Summary collapse

Class Method Details

.call(object, attributes) ⇒ Object

Assign the attributes hash into the object calling attribute writers of the object if the object can respond to them.


10
11
12
13
14
15
16
17
18
# File 'lib/dialers/assign_attributes.rb', line 10

def self.call(object, attributes)
  attributes.each do |key, value|
    writer = "#{key}=".to_sym
    if object.respond_to?(writer)
      object.public_send(writer, value)
    end
  end
  object
end