class Eucalyptus::Resource
Public Class Methods
all(graph: Eucalyptus.graph, parent: self.parent, options: {})
click to toggle source
# File lib/eucalyptus/resource.rb, line 25 def self.all(graph: Eucalyptus.graph, parent: self.parent, options: {}) if options[:fields] options[:fields].concat(self.known_fields).uniq else options[:fields] = self.known_fields end koala_response = graph.get_connection(parent.id, api_path, options) ResponseCollection.new(self, koala_response) end
api_path()
click to toggle source
# File lib/eucalyptus/resource.rb, line 7 def self.api_path raise "You must implement #{__method__.to_s}" end
find(id, fields: [], graph: Eucalyptus.graph)
click to toggle source
# File lib/eucalyptus/resource.rb, line 19 def self.find(id, fields: [], graph: Eucalyptus.graph) fields.concat(self.known_fields).uniq response = graph.get_object(id, fields: fields) self.new(response) end
known_fields()
click to toggle source
# File lib/eucalyptus/resource.rb, line 11 def self.known_fields raise "You must implement #{__method__.to_s}" end
new(response)
click to toggle source
# File lib/eucalyptus/resource.rb, line 37 def initialize(response) @response = Response.new(response) end
parent()
click to toggle source
# File lib/eucalyptus/resource.rb, line 15 def self.parent Eucalyptus.default_account end
Public Instance Methods
ad_sets(options={})
click to toggle source
# File lib/eucalyptus/resource.rb, line 65 def ad_sets(options={}) AdSet.all(parent: self, options: options) end
ads(options={})
click to toggle source
# File lib/eucalyptus/resource.rb, line 57 def ads(options={}) Ad.all(parent: self, options: options) end
campaigns(options={})
click to toggle source
# File lib/eucalyptus/resource.rb, line 61 def campaigns(options={}) Campaign.all(parent: self, options: options) end
delete(graph: Eucalyptus.graph)
click to toggle source
# File lib/eucalyptus/resource.rb, line 53 def delete(graph: Eucalyptus.graph) graph.delete_object(self.id) end
insights(options={})
click to toggle source
# File lib/eucalyptus/resource.rb, line 69 def insights(options={}) Insight.all(parent: self, options: options) end
method_missing(method_sym, *args, &block)
click to toggle source
# File lib/eucalyptus/resource.rb, line 41 def method_missing(method_sym, *args, &block) @response.send(method_sym) end
respond_to?(method_sym, include_private = false)
click to toggle source
# File lib/eucalyptus/resource.rb, line 45 def respond_to?(method_sym, include_private = false) @response.respond_to?(method_sym) end
update(graph: Eucalyptus.graph, fields:)
click to toggle source
# File lib/eucalyptus/resource.rb, line 49 def update(graph: Eucalyptus.graph, fields:) graph.put_connections(self.id, "", fields) end