Sha256: e48131dcf02d1310bc1536154462e9c53912e64e79c59d5d1ee0f147e91b0338

Contents?: true

Size: 678 Bytes

Versions: 7

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

module Leftovers
  module ValueProcessors
    class Singularize
      def initialize(then_processor)
        @then_processor = then_processor

        freeze
      end

      def process(str, node, method_node)
        return unless str

        @then_processor.process(str.singularize, node, method_node)
      rescue NoMethodError
        Leftovers.error <<~MESSAGE
          Tried using the String#singularize method, but the activesupport gem was not available and/or not required
          `gem install activesupport`, and/or add `requires: 'active_support/core_ext/string'` to your .leftovers.yml
        MESSAGE
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
leftovers-0.5.2 lib/leftovers/value_processors/singularize.rb
leftovers-0.5.1 lib/leftovers/value_processors/singularize.rb
leftovers-0.5.0 lib/leftovers/value_processors/singularize.rb
leftovers-0.4.3 lib/leftovers/value_processors/singularize.rb
leftovers-0.4.2 lib/leftovers/value_processors/singularize.rb
leftovers-0.4.1 lib/leftovers/value_processors/singularize.rb
leftovers-0.4.0 lib/leftovers/value_processors/singularize.rb