class FlipFab::CookiePersistence
Constants
- COOKIE_DURATION_MONTHS
- COOKIE_PATH
- DOMAIN_REGEXP
Public Class Methods
new(feature_name, context)
click to toggle source
Calls superclass method
FlipFab::Persistence::new
# File lib/flip_fab/cookie_persistence.rb, line 8 def initialize(feature_name, context) super end
Public Instance Methods
read()
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 12 def read value.to_sym unless value.nil? end
write(state)
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 16 def write(state) context.response.set_cookie key, value: state, expires: cookie_expiration, path: COOKIE_PATH end
Private Instance Methods
host()
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 41 def host context.request.host end
key()
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 24 def key "flip_fab.#{feature_name}" end
top_level_domain()
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 33 def top_level_domain Regexp.last_match(0) if (host !~ /^[\d.]+$/) && (host =~ DOMAIN_REGEXP) end
value()
click to toggle source
# File lib/flip_fab/cookie_persistence.rb, line 28 def value @value ||= context.request.cookies[key] end