Module: Evercookie::ViewHelper

Defined in:
lib/evercookie/view.rb

Overview

module defines view helpers

Instance Method Summary collapse

Instance Method Details

#check_evercookie(key) ⇒ Object

Generates javascript for checking if evercookie exists and getting it's value

Example:

<%= check_evercookie(:key) %>

17
18
19
20
21
22
23
# File 'lib/evercookie/view.rb', line 17

def check_evercookie(key)
  if not session[Evercookie.hash_name_for_get].present?
    session[Evercookie.hash_name_for_get] = {}
  end
  session[Evercookie.hash_name_for_get][:key] = key
  render inline: "<%= javascript_include_tag 'ec', evercookie_get_path -%>"
end

#set_evercookie(key, value) ⇒ Object

Generates javascript for setting evercookie

Example:

<%= set_evercookie(:key, :value) %>

8
9
10
11
# File 'lib/evercookie/view.rb', line 8

def set_evercookie(key, value)
  session[Evercookie.hash_name_for_set] = {key: key, value: value}
  render inline: "<%= javascript_include_tag 'ec', evercookie_set_path -%>"
end