module UserEngage::Operation::Update

Public Instance Methods

update(attributes_hash) click to toggle source

Public: Updates the resources attributes (not the array) with the given attributes_hash.

# File lib/user_engage/operation/update.rb, line 9
def update(attributes_hash)
  update_remote!(attributes_hash) &&
    update_locally!(attributes_hash)
end

Private Instance Methods

update_locally!(attributes_hash) click to toggle source

Private: Updates the instances attributes

# File lib/user_engage/operation/update.rb, line 28
def update_locally!(attributes_hash)
  attributes_hash.each_pair do |attr_name, value|
    attributes[attr_name.to_sym] = value
  end
end
update_remote!(attributes_hash) click to toggle source

Private: Request the update of the attributes on UE

# File lib/user_engage/operation/update.rb, line 21
def update_remote!(attributes_hash)
  path = "/#{resource_name}/#{id}/"
  UserEngage.client.put(path, attributes_hash)
end