Sha256: 47e7d3e370ed6f5d4f674bac375952f19f19e6c8ce46cbf98cecd117cbe251dd

Contents?: true

Size: 955 Bytes

Versions: 3

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

class Serega
  module SeregaPlugins
    module StringModifiers
      # @return [Symbol] Plugin name
      def self.plugin_name
        :string_modifiers
      end

      #
      # Applies plugin code to specific serializer
      #
      # @param serializer_class [Class<Serega>] Current serializer class
      # @param _opts [Hash] Plugin options
      #
      # @return [void]
      #
      def self.load_plugin(serializer_class, **_opts)
        serializer_class.include(InstanceMethods)
        require_relative "parse_string_modifiers"
      end

      #
      # Serega additional/patched instance methods
      #
      # @see Serega
      #
      module InstanceMethods
        private

        def parse_modifier(value)
          return ParseStringModifiers.parse(value) if value.is_a?(String)

          super
        end
      end
    end

    register_plugin(StringModifiers.plugin_name, StringModifiers)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
serega-0.21.0 lib/serega/plugins/string_modifiers/string_modifiers.rb
serega-0.20.1 lib/serega/plugins/string_modifiers/string_modifiers.rb
serega-0.20.0 lib/serega/plugins/string_modifiers/string_modifiers.rb