class TokenPagination::PageToken
Attributes
c_hash[R]
pointer_instance[R]
Public Class Methods
from_string(token_string)
click to toggle source
# File lib/token_pagination/page_token.rb, line 10 def self.from_string(token_string) begin claims, header = JWT.decode(token_string, Rails.application.secrets.secret_key_base) return self.new(claims["_ext"]["c_hash"], claims["_ext"]["pointer_instance"]) rescue JWT::DecodeError => e raise TokenPagination::JWTDecodeError.new("token not decoded: #{e.to_s}") end end
new(c_hash, pointer_instance)
click to toggle source
# File lib/token_pagination/page_token.rb, line 5 def initialize(c_hash, pointer_instance) @c_hash = c_hash @pointer_instance = pointer_instance end
Public Instance Methods
to_s()
click to toggle source
# File lib/token_pagination/page_token.rb, line 19 def to_s JWT.encode({ _ext: { c_hash: @c_hash, pointer_instance: @pointer_instance } }, Rails.application.secrets.secret_key_base) end
verify_c_hash!(c_hash_string)
click to toggle source
# File lib/token_pagination/page_token.rb, line 28 def verify_c_hash!(c_hash_string) if (c_hash_string != self.c_hash) then raise TokenPagination::UnmatchCollectionError.new("c_hash not match") end self end