Module: Sampl

Included in:
Basement
Defined in:
lib/sampl.rb,
lib/sampl/version.rb

Defined Under Namespace

Modules: ClassMethods Classes: Basement

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.app_token(app_token = nil) ⇒ Object



106
107
108
# File 'lib/sampl.rb', line 106

def self.app_token(app_token=nil)
  Basement.app_token(app_token)
end

.endpoint(endpoint = nil) ⇒ Object

change the URI where to send the events. Please note this that chaging this on the static inteface of Sampl directly (Sampl.endpoint=“my.url.com”) will affect the whole app and all tracking calls to Sampl. Thus, all workers in a Rails app will send events to the same endpoint when working with the static interface. Use custom classes when in need for different endpoints.



102
103
104
# File 'lib/sampl.rb', line 102

def self.endpoint(endpoint=nil)
  Basement.endpoint(endpoint)
end

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sampl.rb', line 7

def self.included(base)
  base.extend ClassMethods
  # the following inheritance pattern was explained in this block post by John Nunemaker:
  # http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
  # We borrow its implementation from HTTParty so usage is as close to HTTParty as possible.
  base.send :include, HTTParty::ModuleInheritableAttributes
  base.send(:mattr_inheritable, :default_arguments)
  base.send(:mattr_inheritable, :default_endpoint)
  base.instance_variable_set("@default_arguments", {
    sdk:            "Sampl.rb",
    sdk_version:    Sampl::VERSION,
    event_category: "custom",
    server_side:    true
  })
  base.instance_variable_set("@default_endpoint", "https://events.neurometry.com/sample/v01/event")
end

.server_side(flag = nil) ⇒ Object



110
111
112
# File 'lib/sampl.rb', line 110

def self.server_side(flag=nil)
  Basement.server_side(flag)
end

.track(*args, &block) ⇒ Object



114
115
116
# File 'lib/sampl.rb', line 114

def self.track(*args, &block)
  Basement.track(*args, &block)
end

.version(*args, &block) ⇒ Object



118
119
120
# File 'lib/sampl.rb', line 118

def self.version(*args, &block)
  Basement.version(*args, &block)
end