Sha256: 314032879d2df2449713aa701d0e5ba7a2c9dde3971cfaa5b42a5e812c16686f
Contents?: true
Size: 1.88 KB
Versions: 6
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true class Serega # # Validations # module SeregaValidations # # Validations for attribute params # class CheckAttributeParams # # Validations for attribute params instance methods # module InstanceMethods # @return [Symbol] validated attribute name attr_reader :name # @return [Hash] validated attribute options attr_reader :opts # @return [nil, Proc] validated attribute block attr_reader :block # # Initializes attribute params validator # # @param name [Symbol] attribute name # @param opts [Hash] attribute options # @param block [nil, Proc] block provided to attribute # # @return [void] # def initialize(name, opts, block) @name = name @opts = opts @block = block end # # Validates attribute params # def validate check_name check_opts check_block end private def check_name Attribute::CheckName.call(name) end def check_opts Utils::CheckAllowedKeys.call(opts, allowed_opts_keys) Attribute::CheckOptConst.call(opts, block) Attribute::CheckOptDelegate.call(opts, block) Attribute::CheckOptHide.call(opts) Attribute::CheckOptKey.call(opts, block) Attribute::CheckOptMany.call(opts) Attribute::CheckOptSerializer.call(opts) Attribute::CheckOptValue.call(opts, block) end def check_block Attribute::CheckBlock.call(block) end def allowed_opts_keys self.class.serializer_class.config.attribute_keys end end include InstanceMethods extend Serega::SeregaHelpers::SerializerClassHelper end end end
Version data entries
6 entries across 6 versions & 1 rubygems