Module: Harvest::Behavior::Activatable

Included in:
API::Clients, API::Users
Defined in:
lib/harvest/behavior/activatable.rb

Overview

Activate/Deactivate behaviors that can be brought into API collections

Instance Method Summary collapse

Instance Method Details

#activate(model) ⇒ Harvest::BaseModel

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

Parameters:

Returns:



22
23
24
25
26
27
28
# 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.active = true
  end
  model
end

#deactivate(model) ⇒ Harvest::BaseModel

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

Parameters:

Returns:



10
11
12
13
14
15
16
# 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.active = false
  end
  model
end