Class: Moon::Action::Models::Updater::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/moon/action/models/updater.rb

Overview

Model updater.

Instance Method Summary collapse

Constructor Details

#initialize(model, parameters = { }) ⇒ Model

Returns a new instance of Model.



16
17
18
# File 'lib/moon/action/models/updater.rb', line 16

def initialize(model, parameters = { })
  @model, @parameters = model, parameters
end

Instance Method Details

#updateObject



20
21
22
23
24
25
# File 'lib/moon/action/models/updater.rb', line 20

def update
  @parameters.each do |key, value|
    method_name = "#{key}=".to_sym
    @model.send method_name, value if @model.respond_to?(method_name)
  end
end