Class: ForteRuby::API::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/forte_ruby/api/object.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#request_data

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ForteRuby::API::Base

Instance Attribute Details

#newObject

Returns the value of attribute new.



5
6
7
# File 'lib/forte_ruby/api/object.rb', line 5

def new
  @new
end

Instance Method Details

#deleteObject



7
8
9
# File 'lib/forte_ruby/api/object.rb', line 7

def delete
  send_request(url, :delete)
end

#saveObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/forte_ruby/api/object.rb', line 16

def save
  method_name = new? ? :post : :put

  result = send_request(url, method_name, api_attributes_hash)

  if result.successful? && new?
    set_attributes(result.response.merge(new: false))
  end

  result
end

#update(params) ⇒ Object



11
12
13
14
# File 'lib/forte_ruby/api/object.rb', line 11

def update(params)
  set_attributes(params)
  save
end