class Bernard::Keen::Client

Attributes

config[R]
application_name[R]
project_id[R]
read_key[R]
uri[R]
write_key[R]

Public Class Methods

config=(args) click to toggle source
# File lib/bernard/keen/client.rb, line 19
def config=(args)
  @config = {
    application_name: args[:application_name],
    project_id: args[:project_id],
    write_key: args[:write_key],
    read_key: args[:read_key]
  }
end
configure() { |self| ... } click to toggle source
# File lib/bernard/keen/client.rb, line 15
def configure
  yield self
end
new(args = {}) click to toggle source
# File lib/bernard/keen/client.rb, line 33
def initialize(args = {})
  config = config_from(args)

  @application_name = config.fetch(:application_name, nil)
  @project_id = config.fetch(:project_id, nil)
  @write_key = config.fetch(:write_key, nil)
  @read_key = config.fetch(:read_key, nil)
end

Public Instance Methods

application_name=(value) click to toggle source
# File lib/bernard/keen/client.rb, line 46
def application_name=(value)
  raise(Bernard::ArgumentError, 'Missing application_name') unless value
  @application_name = value
end
connection() click to toggle source
# File lib/bernard/keen/client.rb, line 65
def connection
  Bernard::Connection.new(client: self)
end
project_id=(value) click to toggle source
# File lib/bernard/keen/client.rb, line 51
def project_id=(value)
  raise(Bernard::ArgumentError, 'Missing project_id') unless value
  @project_id = value
end
read_key=(value) click to toggle source
# File lib/bernard/keen/client.rb, line 61
def read_key=(value)
  @read_key = value
end
write_key=(value) click to toggle source
# File lib/bernard/keen/client.rb, line 56
def write_key=(value)
  raise(Bernard::ArgumentError, 'Missing write_key') unless value
  @write_key = value
end

Protected Instance Methods

api_version() click to toggle source
# File lib/bernard/keen/client.rb, line 8
          def api_version
  '3.0'
end

Private Instance Methods

config_from(args) click to toggle source
# File lib/bernard/keen/client.rb, line 69
        def config_from(args)
  if !args.empty?
    args
  elsif Bernard::Keen::Client.config
    Bernard::Keen::Client.config
  else
    {}
  end
end