lib/stub_requests/property/validator.rb in stub_requests-0.1.4 vs lib/stub_requests/property/validator.rb in stub_requests-0.1.5

- old
+ new

@@ -36,11 +36,10 @@ # @raise [InvalidArgumentType] when default does not match type # @raise [PropertyDefined] when property has already been defined # # @return [void] # - # :reek:LongParameterList def self.call(name, type, default, properties) new(name, type, default, properties).run_validations end # @@ -65,16 +64,15 @@ # @param [Symbol] name the name of the property # @param [Class, Module] type the type of the property # @param [Object] default the default value of the property # @param [Hash] properties the list of currently defined properties # - # :reek:LongParameterList def initialize(name, type, default = nil, properties = {}) @type = Array(type).flatten @default = default @name = name - @properties = properties + @properties = properties || {} end # # Performs all validations # @@ -125,9 +123,10 @@ # @raise [PropertyDefined] when property has already been defined # # @return [void] # def validate_undefined + return unless properties return unless (prop = properties[name]) raise PropertyDefined, name: name, type: prop[:type], default: prop[:default] end end