Module: Pathway::Plugins::DryValidation::V1_0::ClassMethods
- Defined in:
- lib/pathway/plugins/dry_validation/v1_0.rb
Instance Attribute Summary collapse
-
#auto_wire ⇒ Object
(also: #auto_wire_options)
Returns the value of attribute auto_wire.
-
#contract_class ⇒ Object
Returns the value of attribute contract_class.
-
#contract_options ⇒ Object
readonly
Returns the value of attribute contract_options.
Instance Method Summary collapse
- #build_contract(**opts) ⇒ Object
- #contract(base = nil, &block) ⇒ Object
- #inherited(subclass) ⇒ Object
Instance Attribute Details
#auto_wire ⇒ Object Also known as: auto_wire_options
Returns the value of attribute auto_wire.
9 10 11 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 9 def auto_wire @auto_wire end |
#contract_class ⇒ Object
Returns the value of attribute contract_class.
8 9 10 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 8 def contract_class @contract_class end |
#contract_options ⇒ Object (readonly)
Returns the value of attribute contract_options.
8 9 10 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 8 def @contract_options end |
Instance Method Details
#build_contract(**opts) ⇒ Object
35 36 37 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 35 def build_contract(**opts) @builded_contract || contract_class.new(**opts) end |
#contract(base = nil, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 14 def contract(base = nil, &block) if block_given? base ||= _base_contract self.contract_class = Class.new(base, &block) elsif base self.contract_class = base else raise ArgumentError, 'Either a contract class or a block must be provided' end end |
#inherited(subclass) ⇒ Object
39 40 41 42 43 |
# File 'lib/pathway/plugins/dry_validation/v1_0.rb', line 39 def inherited(subclass) super subclass.auto_wire = auto_wire subclass.contract_class = contract_class end |