Class: InputStep

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schema.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
# File 'lib/schema.rb', line 1793

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    allow_dependency_failure: d["allow_dependency_failure"] ? AllowDependencyFailureUnion.from_dynamic!(d["allow_dependency_failure"]) : nil,
    branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
    depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
    fields: d["fields"]&.map { |x| Field.from_dynamic!(x) },
    id: d["id"],
    identifier: d["identifier"],
    input_step_if: d["if"],
    input: d["input"],
    key: d["key"],
    label: d["label"],
    input_step_name: d["name"],
    prompt: d["prompt"],
    input_step_type: d["type"]
  )
end

.from_json!(json) ⇒ Object



1812
1813
1814
# File 'lib/schema.rb', line 1812

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
# File 'lib/schema.rb', line 1816

def to_dynamic
  {
    "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
    "branches" => branches&.to_dynamic,
    "depends_on" => depends_on&.to_dynamic,
    "fields" => fields&.map(&:to_dynamic),
    "id" => id,
    "identifier" => identifier,
    "if" => input_step_if,
    "input" => input,
    "key" => key,
    "label" => label,
    "name" => input_step_name,
    "prompt" => prompt,
    "type" => input_step_type
  }
end

#to_json(options = nil) ⇒ Object



1834
1835
1836
# File 'lib/schema.rb', line 1834

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end