Class: TriggerStep

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



2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
# File 'lib/schema.rb', line 2076

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,
    async: d["async"] ? AllowDependencyFailureUnion.from_dynamic!(d["async"]) : nil,
    branches: d["branches"] ? Branches.from_dynamic!(d["branches"]) : nil,
    build: d["build"] ? Build.from_dynamic!(d["build"]) : nil,
    depends_on: d["depends_on"] ? DependsOn.from_dynamic!(d["depends_on"]) : nil,
    id: d["id"],
    identifier: d["identifier"],
    trigger_step_if: d["if"],
    key: d["key"],
    label: d["label"],
    trigger_step_name: d["name"],
    skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
    soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
    trigger: d.fetch("trigger"),
    trigger_step_type: d["type"]
  )
end

.from_json!(json) ⇒ Object



2097
2098
2099
# File 'lib/schema.rb', line 2097

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

Instance Method Details

#to_dynamicObject



2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
# File 'lib/schema.rb', line 2101

def to_dynamic
  {
    "allow_dependency_failure" => allow_dependency_failure&.to_dynamic,
    "async" => async&.to_dynamic,
    "branches" => branches&.to_dynamic,
    "build" => build&.to_dynamic,
    "depends_on" => depends_on&.to_dynamic,
    "id" => id,
    "identifier" => identifier,
    "if" => trigger_step_if,
    "key" => key,
    "label" => label,
    "name" => trigger_step_name,
    "skip" => skip&.to_dynamic,
    "soft_fail" => soft_fail&.to_dynamic,
    "trigger" => trigger,
    "type" => trigger_step_type
  }
end

#to_json(options = nil) ⇒ Object



2121
2122
2123
# File 'lib/schema.rb', line 2121

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