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.13.3 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.13.2 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.13.1 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.13.0 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.12.2 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.12.1 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.12.0 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.12 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.11 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.10 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.9 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.8 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.6 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.5 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.4 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.3 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.2 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.1 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.11.0 app/models/refine/stabilizers/url_encoded_stabilizer.rb
refine-rails-2.10.1 app/models/refine/stabilizers/url_encoded_stabilizer.rb