Module: SmoothOperator::Validations

Included in:
OpenStruct
Defined in:
lib/smooth_operator/validations.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



24
25
26
# File 'lib/smooth_operator/validations.rb', line 24

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#clear_induced_errorsObject



16
17
18
# File 'lib/smooth_operator/validations.rb', line 16

def clear_induced_errors
  @induced_errors = {}
end

#induce_errors(value) ⇒ Object



20
21
22
# File 'lib/smooth_operator/validations.rb', line 20

def induce_errors(value)
  @induced_errors = value
end

#induced_errorsObject



12
13
14
# File 'lib/smooth_operator/validations.rb', line 12

def induced_errors
  @induced_errors ||= {}
end

#invalid?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/smooth_operator/validations.rb', line 8

def invalid?
  !valid?
end

#valid?(context = nil) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/smooth_operator/validations.rb', line 4

def valid?(context = nil)
  Helpers.blank?(induced_errors)
end