Module: Pragma::Operation::Validation::ClassMethods
- Defined in:
- lib/pragma/operation/validation.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#build_contract(resource) ⇒ Pragma::Contract::Base
Builds the contract for the given resource, using the previous defined contract class.
-
#contract(klass) ⇒ Object
Sets the contract to use for validating this operation.
-
#contract_klass ⇒ Class
Returns the contract class.
Instance Method Details
#build_contract(resource) ⇒ Pragma::Contract::Base
Builds the contract for the given resource, using the previous defined contract class.
If no contract has been defined for this operation, simply returns the resource.
37 38 39 40 |
# File 'lib/pragma/operation/validation.rb', line 37 def build_contract(resource) return resource unless contract_klass contract_klass.new(resource) end |
#contract(klass) ⇒ Object
Sets the contract to use for validating this operation.
17 18 19 |
# File 'lib/pragma/operation/validation.rb', line 17 def contract(klass) @contract = klass end |
#contract_klass ⇒ Class
Returns the contract class.
24 25 26 |
# File 'lib/pragma/operation/validation.rb', line 24 def contract_klass @contract end |