Module: NotNaughty::InstanceMethods

Defined in:
lib/not_naughty/instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#errorsObject

Returns instance of Errors.



5
# File 'lib/not_naughty/instance_methods.rb', line 5

def errors() @errors ||= ::NotNaughty::Violation.new end

#valid?Boolean

Returns true if all validations passed

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/not_naughty/instance_methods.rb', line 8

def valid?
  validate
  errors.empty?
end

#validateObject

Clears errors and validates.



14
15
16
17
# File 'lib/not_naughty/instance_methods.rb', line 14

def validate
  errors.clear
  self.class.validator.invoke self
end