Sha256: 5e6c63eb666fc3c39ae9a6e2fc3cf6888a44fa973361f4e75ac9fe32d0429e13

Contents?: true

Size: 464 Bytes

Versions: 15

Compression:

Stored size: 464 Bytes

Contents

module NxtSupport
  module Preprocessors
    class WrongTypeError < StandardError; end

    class DowncasePreprocessor
      attr_accessor :value

      def initialize(value)
        @value = value
      end

      def call
        return if value.nil?

        value.downcase!
        value
      rescue NoMethodError => e
        raise WrongTypeError, "Tried to call #{e.name} on #{value}, but #{value} does not respond to #{e.name}"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
nxt_support-0.6.0 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.5.0 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.4.3 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.4.2 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.4.1 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.4.0 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.3.0 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.2.1 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.2.0 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.16 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.15 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.9 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.8 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.7 lib/nxt_support/preprocessors/downcase_preprocessor.rb
nxt_support-0.1.6 lib/nxt_support/preprocessors/downcase_preprocessor.rb