Module: ModelExtensions::Order::Validations
- Defined in:
- app/api/model_extensions/order.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#include_unset_values? ⇒ Boolean
If this returns true then we check values that have not been set, otherwise we can ignore them.
- #request_options_for_validation ⇒ Object
- #request_types_delegate_validator ⇒ Object
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/api/model_extensions/order.rb', line 10 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.
36 37 38 |
# File 'app/api/model_extensions/order.rb', line 36 def include_unset_values? not building? end |
#request_options_for_validation ⇒ Object
40 41 42 |
# File 'app/api/model_extensions/order.rb', line 40 def RequestOptionForValidation.new({ owner: self }.reverse_merge( || {})) end |
#request_types_delegate_validator ⇒ Object
28 29 30 31 32 |
# File 'app/api/model_extensions/order.rb', line 28 def request_types_delegate_validator DelegateValidation::CompositeValidator.construct( *::RequestType.find(request_types.flatten).map(&:delegate_validator) ) end |