Class: Field
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Field
- Defined in:
- lib/schema.rb
Overview
A list of input fields required to be filled out before unblocking the step
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/schema.rb', line 488 def self.from_dynamic!(d) d = Types::Hash[d] new( field_default: d["default"] ? Branches.from_dynamic!(d["default"]) : nil, field_format: d["format"], hint: d["hint"], key: d.fetch("key"), required: d["required"] ? AllowDependencyFailureUnion.from_dynamic!(d["required"]) : nil, text: d["text"], multiple: d["multiple"] ? AllowDependencyFailureUnion.from_dynamic!(d["multiple"]) : nil, field_options: d["options"]&.map { |x| Option.from_dynamic!(x) }, field_select: d["select"] ) end |
.from_json!(json) ⇒ Object
503 504 505 |
# File 'lib/schema.rb', line 503 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/schema.rb', line 507 def to_dynamic { "default" => field_default&.to_dynamic, "format" => field_format, "hint" => hint, "key" => key, "required" => required&.to_dynamic, "text" => text, "multiple" => multiple&.to_dynamic, "options" => &.map(&:to_dynamic), "select" => field_select } end |
#to_json(options = nil) ⇒ Object
521 522 523 |
# File 'lib/schema.rb', line 521 def to_json( = nil) JSON.generate(to_dynamic, ) end |