class Attribool::Validators::MethodNameValidator
Ensures that if multiple attributes are being defined, and method_name
is provided, that method_name
is a Proc
.
Public Class Methods
new(method_name, number_of_attributes)
click to toggle source
Construct the validator.
@param [Attribool::Attribute] *items
# File lib/attribool/validators/method_name_validator.rb, line 12 def initialize(method_name, number_of_attributes) @method_name = method_name @number_of_attributes = number_of_attributes end
Public Instance Methods
error()
click to toggle source
The exception to raise if validations fail.
@return [ArgumentError] the exception with message
# File lib/attribool/validators/method_name_validator.rb, line 27 def error ArgumentError.new("Must use a Proc when creating multiple methods") end
valid?()
click to toggle source
Is there either one attribute, or is method_name
nil
or a Proc
?
# File lib/attribool/validators/method_name_validator.rb, line 19 def valid? @number_of_attributes == 1 || nil_or_proc? end