Module: Pathway::Plugins::DryValidation::V1_0::ClassMethods

Defined in:
lib/pathway/plugins/dry_validation/v1_0.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auto_wireObject 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_classObject

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_optionsObject (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
  @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