Class: Twelve::API::Gauges::Proxy

Inherits:
ResourceProxy show all
Includes:
Content, Engines, Locations, Referrers, Resolutions, Shares, Technology, Terms, Traffic
Defined in:
lib/twelve/api/gauges.rb

Overview

Gauges::Proxy inherits from Twelve::Proxy and enables defining methods on the proxy object

Instance Attribute Summary

Attributes inherited from ResourceProxy

#attributes, #connection, #path_prefix

Instance Method Summary collapse

Methods included from Locations

#locations

Methods included from Engines

#engines

Methods included from Terms

#terms

Methods included from Technology

#technology

Methods included from Resolutions

#resolutions

Methods included from Traffic

#traffic

Methods included from Referrers

#referrers

Methods included from Content

#content

Methods included from Shares

#share, #shares, #unshare

Methods inherited from ResourceProxy

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Twelve::ResourceProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Twelve::ResourceProxy

Instance Method Details

#create(attributes) ⇒ Object

Creates a gauge

attributes - Hash of attributes

Returns json



31
32
33
# File 'lib/twelve/api/gauges.rb', line 31

def create(attributes)
  connection.post(path_prefix, attributes).body['gauge']
end

#destroyObject

Deletes a gauge

Returns json



39
40
41
# File 'lib/twelve/api/gauges.rb', line 39

def destroy
  connection.delete(path_prefix).body['gauge']
end

#subjectObject

Get gauges, gauge, or update gauge

Returns json



47
48
49
50
51
52
53
54
# File 'lib/twelve/api/gauges.rb', line 47

def subject
  response = if attributes
    connection.put(path_prefix, attributes).body
  else
    connection.get(path_prefix).body
  end
  @subject ||= path_prefix == '/gauges' ? response['gauges'] : response['gauge']
end