Class: Schema
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Schema
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2753 2754 2755 2756 2757 2758 2759 2760 2761 |
# File 'lib/schema.rb', line 2753 def self.from_dynamic!(d) d = Types::Hash[d] new( agents: d["agents"] ? Agents.from_dynamic!(d["agents"]) : nil, env: Types::Hash.optional[d["env"]]&.transform_values { |v| Types::Any[v] }, notify: d["notify"]&.map { |x| SchemaNotify.from_dynamic!(x) }, steps: d.fetch("steps").map { |x| SchemaStep.from_dynamic!(x) } ) end |
.from_json!(json) ⇒ Object
2763 2764 2765 |
# File 'lib/schema.rb', line 2763 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2767 2768 2769 2770 2771 2772 2773 2774 |
# File 'lib/schema.rb', line 2767 def to_dynamic { "agents" => agents&.to_dynamic, "env" => env, "notify" => notify&.map(&:to_dynamic), "steps" => steps.map(&:to_dynamic) } end |
#to_json(options = nil) ⇒ Object
2776 2777 2778 |
# File 'lib/schema.rb', line 2776 def to_json( = nil) JSON.generate(to_dynamic, ) end |