UserVoice SingleSingleOnをRailsアプリと統合するために取り組んでいます。それらは、rubyに次のクラスを提供します。
require 'rubygems'
require 'ezcrypto'
require 'json'
require 'cgi'
require 'base64'
module Uservoice
class Token
attr_accessor :data
USERVOICE_SUBDOMAIN = "FILL IN"
USERVOICE_SSO_KEY = "FILL IN"
def initialize(options = {})
options.merge!({:expires => (Time.zone.now.utc + 5 * 60).to_s})
key = EzCrypto::Key.with_password USERVOICE_SUBDOMAIN, USERVOICE_SSO_KEY
encrypted = key.encrypt(options.to_json)
@data = Base64.encode64(encrypted).gsub(/\n/,'') # Remove line returns where are annoyingly placed every 60 characters
end
def to_s
@data
end
end
end
私が理解できないのは、これの使い方です。このファイルをlibディレクトリに追加し、Railsコンソールを使用して実行しています。私は試した:
1.9.3-p125 :013 > Uservoice::Token
=> Uservoice::Token
しかし、実際にオプションを返すようにすることはできません。
Uservoice::Token.new(:guid => 1, :display_name => "jeff goldmen", :email => "jeff@google.com")
これを実際に使用する方法はありますか?ありがとう