Class: RestMyCase::Validator

Inherits:
Base
  • Object
show all
Extended by:
AccusationAttorneys::HelperMethods, ClassMethods
Defined in:
lib/rest_my_case/validator.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from ClassMethods

#validators

Attributes inherited from Base

#context, #dependent_use_case, #options

Attributes included from Config::Base

#parent_dependencies_first, #silence_dependencies_abort

Instance Method Summary collapse

Methods included from ClassMethods

trial_court, validate, validates_with

Methods included from AccusationAttorneys::HelperMethods

_merge_attributes, validates_format_of, validates_length_of, validates_numericality_of, validates_presence_of

Methods inherited from Base

#abort, #abort!, context_accessor, context_reader, context_writer, dependencies, depends, #error, #error!, #final, #initialize, #invoke, #invoke!, perform, #rollback, #setup, #skip, #skip!, trial_court, trial_court=

Constructor Details

This class inherits a constructor from RestMyCase::Base

Instance Method Details

#performObject



75
76
77
78
79
80
81
82
83
# File 'lib/rest_my_case/validator.rb', line 75

def perform
  targets = [*target]

  if targets.empty?
    error('no target to validate!')
  else
    error('unprocessable_entity') unless all_validations_green? targets
  end
end

#targetObject



69
70
71
72
73
# File 'lib/rest_my_case/validator.rb', line 69

def target
  return nil if target_name.nil?

  respond_to?(target_name) ? send(target_name) : context.send(target_name)
end

#target_nameObject



65
66
67
# File 'lib/rest_my_case/validator.rb', line 65

def target_name
  self.class.target_name
end