Sha256: bc1b642af5e7143708696c117b9ecfd077d840fa47c51e3b28148045f44b08b3

Contents?: true

Size: 1.42 KB

Versions: 13

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

class Serega
  module SeregaPlugins
    module Batch
      #
      # Extensions (mini-plugins) that are enabled when :batch plugin used with other plugins
      #
      module PluginsExtensions
        #
        # Extension that is used when batch plugin used with :formatters plugin
        #
        module Formatters
          #
          # BatchLoader additional/patched instance methods
          #
          # @see Serega::SeregaPlugins::Batch::SeregaBatchLoader
          #
          module BatchLoaderInstanceMethods
            private

            # Format values after they are prepared
            def keys_values
              data = super

              formatter = point.attribute.formatter
              data.transform_values! { |value| formatter.call(value) } if formatter

              data
            end
          end

          #
          # SeregaAttribute additional/patched instance methods
          #
          # @see Serega::SeregaAttribute
          #
          module SeregaAttributeInstanceMethods
            # Normalized formatter block or callable instance
            # @return [#call, nil] Normalized formatter block or callable instance
            attr_reader :formatter

            private

            def set_normalized_vars(normalizer)
              super
              @formatter = normalizer.formatter
            end
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
serega-0.21.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.20.1 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.20.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.19.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.18.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.17.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.16.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.15.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.14.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.12.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.11.2 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.11.1 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
serega-0.11.0 lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb