Sha256: 9b3b9830bf02f2c92998564c6ef954e897df74d425432b3a76114660047153e1

Contents?: true

Size: 963 Bytes

Versions: 4

Compression:

Stored size: 963 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] Loaded plugins 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

4 entries across 4 versions & 1 rubygems

Version Path
serega-0.19.0 lib/serega/plugins/string_modifiers/string_modifiers.rb
serega-0.18.0 lib/serega/plugins/string_modifiers/string_modifiers.rb
serega-0.17.0 lib/serega/plugins/string_modifiers/string_modifiers.rb
serega-0.16.0 lib/serega/plugins/string_modifiers/string_modifiers.rb