module Harvest::Behavior::Activatable

Activate/Deactivate behaviors that can be brought into API collections

Public Instance Methods

activate(model) click to toggle source

Activates the item. Does nothing if the item is already activated

@param [Harvest::BaseModel] model the model you want to activate @return [Harvest::BaseModel] the activated model

# File lib/harvest/behavior/activatable.rb, line 22
def activate(model)
  if !model.active?
    request(:post, credentials, "#{api_model.api_path}/#{model.to_i}/toggle")
    model.is_active = true
  end
  model
end
deactivate(model) click to toggle source

Deactivates the item. Does nothing if the item is already deactivated

@param [Harvest::BaseModel] model the model you want to deactivate @return [Harvest::BaseModel] the deactivated model

# File lib/harvest/behavior/activatable.rb, line 10
def deactivate(model)
  if model.active?
    request(:post, credentials, "#{api_model.api_path}/#{model.to_i}/toggle")
    model.is_active = false
  end
  model
end