Class: Datapimp::Clients::Keen

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/datapimp/clients/keen.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.client(options = {}) ⇒ Object



14
15
16
# File 'lib/datapimp/clients/keen.rb', line 14

def self.client(options={})
  Keen
end

.method_missing(meth, *args, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/datapimp/clients/keen.rb', line 6

def self.method_missing(meth, *args, &block)
  if client.respond_to?(meth)
    return client.send(meth, *args, &block)
  end

  super
end

Instance Method Details

#optionsObject



18
19
20
# File 'lib/datapimp/clients/keen.rb', line 18

def options
  @options ||= {}
end

#setup(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/datapimp/clients/keen.rb', line 27

def setup(options={})
  access_token = options[:keen_read_key] || Datapimp.config.keen_read_key
  project_id = options[:keen_project_id] || Datapimp.config.keen_project_id

  unless access_token.to_s.length > 1
    if respond_to?(:ask)
      access_token = ask("Enter a keen read key when  you have one", String)
    end
  end

  unless project_id.to_s.length > 1
    if respond_to?(:ask)
      project_id = ask("Enter a keen read key when  you have one", String)
    end
  end

  Datapimp.config.set(:keen_read_key, access_token) if access_token.to_s.length > 1
  Datapimp.config.set(:keen_project_id, project_id) if project_id.to_s.length > 1
end

#with_options(opts = {}) ⇒ Object



22
23
24
25
# File 'lib/datapimp/clients/keen.rb', line 22

def with_options(opts={})
  options.merge!(opts)
  self
end