class FlipFab::CookiePersistence

Constants

DOMAIN_REGEXP

See: github.com/rails/rails/blob/b1124a2ac88778c0feb0157ac09367cbd204bf01/actionpack/lib/action_dispatch/middleware/cookies.rb#L214

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

See: github.com/rails/rails/blob/b1124a2ac88778c0feb0157ac09367cbd204bf01/actionpack/lib/action_dispatch/middleware/cookies.rb#L286-L294

# 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