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 19 |
# 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.
37 38 39 |
# File 'app/api/model_extensions/order.rb', line 37 def include_unset_values? not building? end |
#request_options_for_validation ⇒ Object
41 42 43 |
# File 'app/api/model_extensions/order.rb', line 41 def RequestOptionForValidation.new({ owner: self }.reverse_merge( || {})) end |
#request_types_delegate_validator ⇒ Object
29 30 31 32 33 |
# File 'app/api/model_extensions/order.rb', line 29 def request_types_delegate_validator DelegateValidation::CompositeValidator.construct( *::RequestType.find(request_types.flatten).map(&:delegate_validator) ) end |