Class: ContextIO::Source

Inherits:
Object
  • Object
show all
Includes:
API::Resource
Defined in:
lib/contextio/source.rb

Instance Attribute Summary collapse

Attributes included from API::Resource

#api_attributes, #primary_key, #resource_url

Instance Method Summary collapse

Instance Attribute Details

#use_ssl?Boolean (readonly)

Returns:

  • (Boolean)


19
20
21
# File 'lib/contextio/source.rb', line 19

def use_ssl?
  use_ssl
end

Instance Method Details

#deleteObject



43
44
45
# File 'lib/contextio/source.rb', line 43

def delete
  api.request(:delete, resource_url)['success']
end

#sync!(options = {}) ⇒ Object



57
58
59
# File 'lib/contextio/source.rb', line 57

def sync!(options={})
  api.request(:post, "#{resource_url}/sync", options)['success']
end

#sync_dataObject



47
48
49
50
51
52
53
54
55
# File 'lib/contextio/source.rb', line 47

def sync_data
  return @sync_data if @sync_data

  sync_hashes = api.request(:get, "#{resource_url}/sync")

  @sync_data = ContextIO::SourceSyncData.new(label, sync_hashes)

  return @sync_data
end

#update(options = {}) ⇒ Object

Updates the source.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/contextio/source.rb', line 29

def update(options={})
  it_worked = api.request(:post, resource_url, options)['success']

  if it_worked
    options.each do |key, value|
      key = key.to_s.gsub('-', '_')

      instance_variable_set("@#{key}", value)
    end
  end

  it_worked
end