Class: Blackbeard::Pirate
- Inherits:
-
Object
- Object
- Blackbeard::Pirate
- Defined in:
- lib/blackbeard/pirate.rb
Instance Method Summary collapse
- #ab_test(id, options) ⇒ Object
- #add_total(id, amount) ⇒ Object
- #add_unique(id) ⇒ Object
- #clear_context ⇒ Object
- #context(*args) ⇒ Object
- #feature(id) ⇒ Object
- #feature_active?(id) ⇒ Boolean
-
#initialize ⇒ Pirate
constructor
A new instance of Pirate.
- #metric(type, type_id) ⇒ Object
- #set_context(*args) ⇒ Object
- #test(id) ⇒ Object
Constructor Details
#initialize ⇒ Pirate
Returns a new instance of Pirate.
12 13 14 15 16 |
# File 'lib/blackbeard/pirate.rb', line 12 def initialize @metrics = {} @tests = {} @features = {} end |
Instance Method Details
#ab_test(id, options) ⇒ Object
52 53 54 55 |
# File 'lib/blackbeard/pirate.rb', line 52 def ab_test(id, ) return self unless @set_context @set_context.ab_test(id, ) end |
#add_total(id, amount) ⇒ Object
47 48 49 50 |
# File 'lib/blackbeard/pirate.rb', line 47 def add_total(id, amount) return self unless @set_context @set_context.add_total(id, amount) end |
#add_unique(id) ⇒ Object
42 43 44 45 |
# File 'lib/blackbeard/pirate.rb', line 42 def add_unique(id) return self unless @set_context @set_context.add_unique(id) end |
#clear_context ⇒ Object
38 39 40 |
# File 'lib/blackbeard/pirate.rb', line 38 def clear_context @set_context = nil end |
#context(*args) ⇒ Object
30 31 32 |
# File 'lib/blackbeard/pirate.rb', line 30 def context(*args) Context.new(self, *args) end |
#feature(id) ⇒ Object
26 27 28 |
# File 'lib/blackbeard/pirate.rb', line 26 def feature(id) @features[id] ||= Feature.find_or_create(id) end |
#feature_active?(id) ⇒ Boolean
57 58 59 60 |
# File 'lib/blackbeard/pirate.rb', line 57 def feature_active?(id) return false unless @set_context @set_context.feature_active?(id) end |
#metric(type, type_id) ⇒ Object
18 19 20 |
# File 'lib/blackbeard/pirate.rb', line 18 def metric(type, type_id) @metrics["#{type}::#{type_id}"] ||= Metric.find_or_create(type, type_id) end |
#set_context(*args) ⇒ Object
34 35 36 |
# File 'lib/blackbeard/pirate.rb', line 34 def set_context(*args) @set_context = context(*args) end |
#test(id) ⇒ Object
22 23 24 |
# File 'lib/blackbeard/pirate.rb', line 22 def test(id) @tests[id] ||= Test.find_or_create(id) end |