<commit_before># Uses cookie to determine feature state.
module Flip
  class CookieStrategy < AbstractStrategy

    def description
      "Uses cookies to apply only to your session."
    end

    def knows? definition
      cookies.key? cookie_name(definition)
    end

    def on? definition
      cookies[cookie_name(definition)] === "true"
    end

    def switchable?
      true
    end

    def switch! key, on
      cookies[cookie_name(key)] = on ? "true" : "false"
    end

    def delete! key
      cookies.delete cookie_name(key)
    end

    def self.cookies= cookies
      @cookies = cookies
    end
<commit_msg>fix cookie strategy to work with for all subdomains<commit_after># Uses cookie to determine feature state.
module Flip
  class CookieStrategy < AbstractStrategy

    def description
      "Uses cookies to apply only to your session."
    end

    def knows? definition
      cookies.key? cookie_name(definition)
    end

    def on? definition
      cookie = cookies[cookie_name(definition)]
      cookie_value = cookie.is_a?(Hash) ? cookie['value'] : cookie
      cookie_value === 'true'
    end

    def switchable?
      true
    end

    def switch! key, on
      cookies[cookie_name(key)] = {
        'value' => (on ? "true" : "false"),
        'domain' => :all
      }
    end

    def delete! key
      cookies.delete cookie_name(key)
    end

    def self.cookies= cookies
      @cookies = cookies
    end

{'fraction_non_alphanumeric': 0.08205841446453407, 'fraction_numerical': 0.0, 'mean_word_length': 2.45083932853717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2104774', 'n_tokens_mistral': 426, 'n_tokens_neox': 417, 'n_words': 137}