Sha256: b261d20744851484714d23828f32ca3c63a7726fbb34257a1e6ac682f55f79fe

Contents?: true

Size: 648 Bytes

Versions: 53

Compression:

Stored size: 648 Bytes

Contents

require "active_support/parameter_filter"

class Jets::Controller
  class ParametersFilter
    attr_reader :filters, :params_filter

    def initialize(filters)
      @filters = filters
      @params_filter = ActiveSupport::ParameterFilter.new(filters)
    end

    def filter(params)
      params && params_filter.filter(params)
    end

    def filter_json(json_text)
      return json_text if filters.blank? || json_text.blank?

      begin
        hash_params = JSON.parse(json_text)
        filtered_params = filter(hash_params)
        JSON.dump(filtered_params)
      rescue JSON::ParserError
        String.new
      end
    end

  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
jets-4.0.12 lib/jets/controller/parameters_filter.rb
jets-4.0.11 lib/jets/controller/parameters_filter.rb
jets-4.0.10 lib/jets/controller/parameters_filter.rb
jets-4.0.9 lib/jets/controller/parameters_filter.rb
jets-4.0.8 lib/jets/controller/parameters_filter.rb
jets-4.0.7 lib/jets/controller/parameters_filter.rb
jets-4.0.6 lib/jets/controller/parameters_filter.rb
jets-4.0.5 lib/jets/controller/parameters_filter.rb
jets-4.0.4 lib/jets/controller/parameters_filter.rb
jets-4.0.3 lib/jets/controller/parameters_filter.rb
jets-4.0.2 lib/jets/controller/parameters_filter.rb
jets-4.0.1 lib/jets/controller/parameters_filter.rb
jets-4.0.0 lib/jets/controller/parameters_filter.rb
jets-3.2.2 lib/jets/controller/parameters_filter.rb
jets-3.2.1 lib/jets/controller/parameters_filter.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/controller/parameters_filter.rb
jets-3.2.0 lib/jets/controller/parameters_filter.rb
jets-3.1.5 lib/jets/controller/parameters_filter.rb
jets-3.1.4 lib/jets/controller/parameters_filter.rb
jets-3.1.3 lib/jets/controller/parameters_filter.rb