Sha256: 08794b77089f1316a520fae91517ef1afb21b8df7279912f9077b70e45b7b044
Contents?: true
Size: 719 Bytes
Versions: 36
Compression:
Stored size: 719 Bytes
Contents
module Refine module Stabilizers class UrlEncodedStabilizer def to_stable_id(filter:) compressed_state = ActiveSupport::Gzip.compress(filter.state) encoded_state = Base64.encode64(compressed_state) CGI.escape(encoded_state) end def from_stable_id(id:, initial_query: nil) raise Refine::Stabilizers::Errors::UrlStabilizerError if id.blank? url_decoded = CGI.unescape(id) base_64_decoded = Base64.decode64(url_decoded) uncompress = ActiveSupport::Gzip.decompress(base_64_decoded) state = ActiveSupport::JSON.decode(uncompress).deep_symbolize_keys Refine::Filter.from_state(state, initial_query) end end end end
Version data entries
36 entries across 36 versions & 1 rubygems