Class: Growthbook::InMemoryStickyBucketService

Inherits:
StickyBucketService show all
Defined in:
lib/growthbook/sticky_bucket_service.rb

Overview

Sample implementation (not meant for production use)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StickyBucketService

#get_all_assignments, #get_key

Constructor Details

#initializeInMemoryStickyBucketService

Returns a new instance of InMemoryStickyBucketService.



32
33
34
35
# File 'lib/growthbook/sticky_bucket_service.rb', line 32

def initialize
  super
  @assignments = {}
end

Instance Attribute Details

#assignmentsObject

Returns the value of attribute assignments.



30
31
32
# File 'lib/growthbook/sticky_bucket_service.rb', line 30

def assignments
  @assignments
end

Instance Method Details

#get_assignments(attribute_name, attribute_value) ⇒ Object



37
38
39
# File 'lib/growthbook/sticky_bucket_service.rb', line 37

def get_assignments(attribute_name, attribute_value)
  @assignments[get_key(attribute_name, attribute_value)]
end

#save_assignments(doc) ⇒ Object



41
42
43
# File 'lib/growthbook/sticky_bucket_service.rb', line 41

def save_assignments(doc)
  @assignments[get_key(doc['attributeName'], doc['attributeValue'])] = doc
end