Module: ModelExtensions::Order::Validations

Defined in:
app/api/model_extensions/order.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


9
10
11
12
13
14
# File 'app/api/model_extensions/order.rb', line 9

def self.included(base)
  base.class_eval do
    extend DelegateValidation
    delegate_validation :request_options_for_validation, as: 'request_options', to: :request_types, if: :validate_request_options?
  end
end

Instance Method Details

#include_unset_values?Boolean

If this returns true then we check values that have not been set, otherwise we can ignore them. This would mean that we should not require values that are unset, until we're moving out of the building state.

Returns:

  • (Boolean)

30
31
32
# File 'app/api/model_extensions/order.rb', line 30

def include_unset_values?
  not building?
end

#request_options_for_validationObject


34
35
36
# File 'app/api/model_extensions/order.rb', line 34

def request_options_for_validation
  RequestOptionForValidation.new({ owner: self }.reverse_merge(request_options || {}))
end

#request_types_delegate_validatorObject


24
25
26
# File 'app/api/model_extensions/order.rb', line 24

def request_types_delegate_validator
  DelegateValidation::CompositeValidator.construct(*::RequestType.find(request_types.flatten).map(&:delegate_validator))
end