Sha256: 893d888e9ac3839bb6cf3cd9e9f3e568d679d65c1fb64499a5fb77b2632e30b0

Contents?: true

Size: 908 Bytes

Versions: 7

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

class Serega
  module SeregaValidations
    class CheckInitiateParams
      module InstanceMethods
        attr_reader :opts

        def initialize(opts)
          @opts = opts
        end

        def validate
          check_allowed_keys
          check_modifiers
        end

        private

        def check_allowed_keys
          Utils::CheckAllowedKeys.call(opts, serializer_class.config.initiate_keys)
        end

        def check_modifiers
          Initiate::CheckModifiers.call(serializer_class, opts[:only])
          Initiate::CheckModifiers.call(serializer_class, opts[:except])
          Initiate::CheckModifiers.call(serializer_class, opts[:with])
        end

        def serializer_class
          self.class.serializer_class
        end
      end

      include InstanceMethods
      extend Serega::SeregaHelpers::SerializerClassHelper
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
serega-0.6.1 lib/serega/validations/check_initiate_params.rb
serega-0.6.0 lib/serega/validations/check_initiate_params.rb
serega-0.5.2 lib/serega/validations/check_initiate_params.rb
serega-0.5.1 lib/serega/validations/check_initiate_params.rb
serega-0.5.0 lib/serega/validations/check_initiate_params.rb
serega-0.4.0 lib/serega/validations/check_initiate_params.rb
serega-0.3.0 lib/serega/validations/check_initiate_params.rb