Module: AlondraHelper

Defined in:
app/helpers/alondra_helper.rb

Instance Method Summary collapse

Instance Method Details

#alondra_subscribe(resources) ⇒ Object



13
14
15
16
17
18
# File 'app/helpers/alondra_helper.rb', line 13

def alondra_subscribe(resources)
  resources = [resources] unless Enumerable === resources
  resources_paths = resources.collect { |r| "'#{polymorphic_path(r)}'" }.join(', ')

  "new AlondraClient('#{Alondra::Alondra.config.host}', #{Alondra::Alondra.config.port}, [#{resources_paths}]);"
end

#alondra_subscribe_tag(resources) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/helpers/alondra_helper.rb', line 3

def alondra_subscribe_tag(resources)
  javascript_tag do
    %Q{
      $(function(){
        #{alondra_subscribe(resources)}
      });
    }
  end
end

#encrypted_tokenObject



20
21
22
23
# File 'app/helpers/alondra_helper.rb', line 20

def encrypted_token
  token = {:user_id => current_user.id, :valid_until => 5.minutes.from_now}.to_json
  Alondra::SessionParser.verifier.generate(token)
end