Class: Slack2

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



1363
1364
1365
1366
1367
1368
1369
# File 'lib/schema.rb', line 1363

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    channels: d["channels"],
    message: d["message"]
  )
end

.from_json!(json) ⇒ Object



1371
1372
1373
# File 'lib/schema.rb', line 1371

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

Instance Method Details

#to_dynamicObject



1375
1376
1377
1378
1379
1380
# File 'lib/schema.rb', line 1375

def to_dynamic
  {
    "channels" => channels,
    "message" => message
  }
end

#to_json(options = nil) ⇒ Object



1382
1383
1384
# File 'lib/schema.rb', line 1382

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