Module: Easyop::Schema::ClassMethods
- Defined in:
- lib/easyop/schema.rb
Instance Method Summary collapse
- #_param_schema ⇒ Object
- #_result_schema ⇒ Object
-
#params(&block) ⇒ Object
(also: #inputs)
Declare input schema.
-
#result(&block) ⇒ Object
(also: #outputs)
Declare output schema.
Instance Method Details
#_param_schema ⇒ Object
51 52 53 |
# File 'lib/easyop/schema.rb', line 51 def _param_schema @_param_schema end |
#_result_schema ⇒ Object
55 56 57 |
# File 'lib/easyop/schema.rb', line 55 def _result_schema @_result_schema end |
#params(&block) ⇒ Object Also known as: inputs
Declare input schema. Validated before ‘call` runs.
31 32 33 34 35 36 37 38 |
# File 'lib/easyop/schema.rb', line 31 def params(&block) schema = FieldSchema.new schema.instance_eval(&block) @_param_schema = schema # Register as a before hook (prepend so it runs first) _before_hooks.unshift(:_validate_params!) end |
#result(&block) ⇒ Object Also known as: outputs
Declare output schema. Validated after ‘call` returns (not in ensure).
42 43 44 45 46 47 48 |
# File 'lib/easyop/schema.rb', line 42 def result(&block) schema = FieldSchema.new schema.instance_eval(&block) @_result_schema = schema _after_hooks.push(:_validate_result!) end |