Class: Sunnytrail
- Inherits:
-
Object
show all
- Defined in:
- lib/sunnytrail.rb
Defined Under Namespace
Classes: ConfigurationError, Event
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(init_options = {}) ⇒ Sunnytrail
47
48
49
50
51
|
# File 'lib/sunnytrail.rb', line 47
def initialize(init_options={})
@options = Sunnytrail.options.merge(init_options)
start_logger if verbose?
raise ConfigurationError, "API KEY not set" if @options[:api_key].nil?
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
13
14
15
|
# File 'lib/sunnytrail.rb', line 13
def options
@options
end
|
Class Method Details
.add_event(args = {}) ⇒ Object
37
38
39
40
|
# File 'lib/sunnytrail.rb', line 37
def add_event(args={})
@sunny_trail ||= Sunnytrail.new
@sunny_trail.add_event(args)
end
|
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/sunnytrail.rb', line 19
def configure(options = {}, &block)
default_options = {
:api_url => "api.thesunnytrail.com",
:api_key => nil,
:use_ssl => true,
:verbose => false,
:send_events => true,
:log_path => 'sunnytrail.log'
}
block.call(options) if block_given?
@options = default_options.merge(options)
end
|
.options ⇒ Object
33
34
35
|
# File 'lib/sunnytrail.rb', line 33
def options
@options ||= {}
end
|
Instance Method Details
#add_event(args = {}) ⇒ Object
53
54
55
56
57
|
# File 'lib/sunnytrail.rb', line 53
def add_event(args={})
message = args.to_json
@logger.info("Event sent: #{message}") if verbose?
request(message) if @options[:send_events]
end
|
#verbose? ⇒ Boolean
59
60
61
|
# File 'lib/sunnytrail.rb', line 59
def verbose?
!!@options[:verbose]
end
|