Class: RestMyCase::Validator

Inherits:
Base
  • Object
show all
Includes:
ObjectAttorney
Defined in:
lib/rest_my_case/validator.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #options

Attributes included from Config::Base

#parent_dependencies_first, #silence_dependencies_abort

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from RestMyCase::Base

Class Method Details

.target(name, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rest_my_case/validator.rb', line 7

def self.target(name, options = {})
  defend(name, options)

  if defendant_options[:in].present?
    context_reader defendant_options[:in]
  else
    context_reader name
  end
end

Instance Method Details

#performObject



21
22
23
24
25
# File 'lib/rest_my_case/validator.rb', line 21

def perform
  return if defendant_options.empty?

  error('unprocessable_entity') if invalid?
end