Class: DrySchemaRails::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dry_schema_rails/base.rb

Class Method Summary collapse

Class Method Details

._schema_procObject



6
7
8
# File 'lib/dry_schema_rails/base.rb', line 6

def _schema_proc
  @_schema_proc ||= -> {}
end

._schema_proc=(proc) ⇒ Object



10
11
12
# File 'lib/dry_schema_rails/base.rb', line 10

def _schema_proc=(proc)
  @_schema_proc = proc
end

.call(*args) ⇒ Object



14
15
16
# File 'lib/dry_schema_rails/base.rb', line 14

def call(*args)
  params.call(*args)
end

.paramsObject Also known as: contract



18
19
20
# File 'lib/dry_schema_rails/base.rb', line 18

def params
  Dry::Schema.Params(&_schema_proc)
end

.schema(&block) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/dry_schema_rails/base.rb', line 24

def schema(&block)
  if block_given?
    self._schema_proc = block
  else
    _schema_proc
  end
end