Class: Keen::Client
- Inherits:
-
Object
- Object
- Keen::Client
- Includes:
- PublishingMethods, QueryingMethods
- Defined in:
- lib/keen/client.rb,
lib/keen/client/querying_methods.rb,
lib/keen/client/publishing_methods.rb
Defined Under Namespace
Modules: PublishingMethods, QueryingMethods
Constant Summary collapse
- CONFIG =
{ :api_url => "https://api.keen.io", :api_version => "3.0", :api_headers => lambda { |, sync_or_async| user_agent = "keen-gem, v#{Keen::VERSION}, #{sync_or_async}" user_agent += ", #{RUBY_VERSION}, #{RUBY_PLATFORM}, #{RUBY_PATCHLEVEL}" if defined?(RUBY_ENGINE) user_agent += ", #{RUBY_ENGINE}" end { "Content-Type" => "application/json", "User-Agent" => user_agent, "Authorization" => } } }
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#read_key ⇒ Object
Returns the value of attribute read_key.
-
#write_key ⇒ Object
Returns the value of attribute write_key.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Client
constructor
A new instance of Client.
Methods included from QueryingMethods
#average, #count, #count_unique, #extraction, #funnel, #maximum, #minimum, #multi_analysis, #select_unique, #sum
Methods included from PublishingMethods
#add_event, #beacon_url, #publish, #publish_async
Constructor Details
#initialize(*args) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/keen/client.rb', line 32 def initialize(*args) = args[0] unless .is_a?(Hash) # deprecated, pass a hash of options instead = { :project_id => args[0], :write_key => args[1], :read_key => args[2], }.merge(args[3] || {}) end self.project_id, self.write_key, self.read_key = .values_at( :project_id, :write_key, :read_key) self.api_url = [:api_url] || CONFIG[:api_url] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(_method, *args, &block) ⇒ Object (private)
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/keen/client.rb', line 83 def method_missing(_method, *args, &block) if config = CONFIG[_method.to_sym] if config.is_a?(Proc) config.call(*args) else config end else super end end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
15 16 17 |
# File 'lib/keen/client.rb', line 15 def api_url @api_url end |
#project_id ⇒ Object
Returns the value of attribute project_id.
15 16 17 |
# File 'lib/keen/client.rb', line 15 def project_id @project_id end |
#read_key ⇒ Object
Returns the value of attribute read_key.
15 16 17 |
# File 'lib/keen/client.rb', line 15 def read_key @read_key end |
#write_key ⇒ Object
Returns the value of attribute write_key.
15 16 17 |
# File 'lib/keen/client.rb', line 15 def write_key @write_key end |