Sha256: 6e5c13d648fc50e0b1561ee4bc2c4afb160a23a584eddc1bd4d9fb30484531e6

Contents?: true

Size: 665 Bytes

Versions: 4

Compression:

Stored size: 665 Bytes

Contents

module AlondraHelper

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

  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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alondra-0.1.1 app/helpers/alondra_helper.rb
alondra-0.1.0 app/helpers/alondra_helper.rb
alondra-0.0.4 app/helpers/alondra_helper.rb
alondra-0.0.3 app/helpers/alondra_helper.rb