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

Version Path
refine-rails-2.10.0 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.14 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.13 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.12 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.11 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.10 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.9 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.8 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.7 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.6 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.5 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.4 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.3 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.2 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.1 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.9.0 app/models/refine/stabilizers/url_encoded_stabilizer.rb