Sha256: ce9d01d1a0d799f7d2ac9ebbe429fc32efcfeb692e5b938453357c90bb498199

Contents?: true

Size: 572 Bytes

Versions: 32

Compression:

Stored size: 572 Bytes

Contents

require "action_controller"

module Plutonium
  module Refinements
    module ParameterRefinements
      refine ActionController::Parameters do
        def nilify
          transform_values { |value| nilify_internal value }
        end

        private

        def nilify_internal(value)
          case value
          when String
            value.presence
          when Hash
            nilify value
          when Array
            value.map { |val| nilify_internal val }.compact
          else
            value
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
plutonium-0.15.4 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.3 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.2 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.1 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.0 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.0.pre.rc3 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.0.pre.rc2 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.15.0.pre.rc1 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.14.1 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.14.0 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.13.3 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.13.2 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.13.1 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.13.0 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.14 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.13 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.12 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.11 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.10 lib/plutonium/refinements/parameter_refinements.rb
plutonium-0.12.9 lib/plutonium/refinements/parameter_refinements.rb