Sha256: 2d129a8f7b849f3ebb10107e8ff0a04873ade0d98ccc8452f2334be852cc0cd9

Contents?: true

Size: 673 Bytes

Versions: 5

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require "active_support/core_ext/hash/indifferent_access"

class ProtectedParams
  delegate :keys, :key?, :has_key?, :empty?, to: :@parameters

  def initialize(parameters = {})
    @parameters = parameters.with_indifferent_access
    @permitted = false
  end

  def permitted?
    @permitted
  end

  def permit!
    @permitted = true
    self
  end

  def [](key)
    @parameters[key]
  end

  def to_h
    @parameters.to_h
  end
  alias to_unsafe_h to_h

  def each_pair(&block)
    @parameters.each_pair(&block)
  end

  def dup
    super.tap do |duplicate|
      duplicate.instance_variable_set :@permitted, @permitted
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ibm_db-5.5.0 test/support/stubs/strong_parameters.rb
ibm_db-5.4.1 test/support/stubs/strong_parameters.rb
ibm_db-5.4.0 test/support/stubs/strong_parameters.rb
ibm_db-5.3.2 test/support/stubs/strong_parameters.rb
ibm_db-5.3.1 test/support/stubs/strong_parameters.rb