Class: NotifyClass

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



1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
# File 'lib/schema.rb', line 1424

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    basecamp_campfire: d["basecamp_campfire"],
    notify_if: d["if"],
    slack: d["slack"] ? Slack5.from_dynamic!(d["slack"]) : nil,
    github_commit_status: d["github_commit_status"] ? GithubCommitStatus2.from_dynamic!(d["github_commit_status"]) : nil,
    github_check: Types::Hash.optional[d["github_check"]]&.transform_values { |v| Types::Any[v] }
  )
end

.from_json!(json) ⇒ Object



1435
1436
1437
# File 'lib/schema.rb', line 1435

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

Instance Method Details

#to_dynamicObject



1439
1440
1441
1442
1443
1444
1445
1446
1447
# File 'lib/schema.rb', line 1439

def to_dynamic
  {
    "basecamp_campfire" => basecamp_campfire,
    "if" => notify_if,
    "slack" => slack&.to_dynamic,
    "github_commit_status" => github_commit_status&.to_dynamic,
    "github_check" => github_check
  }
end

#to_json(options = nil) ⇒ Object



1449
1450
1451
# File 'lib/schema.rb', line 1449

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