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



1361
1362
1363
1364
1365
1366
1367
# File 'lib/schema.rb', line 1361

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

.from_json!(json) ⇒ Object



1369
1370
1371
# File 'lib/schema.rb', line 1369

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

Instance Method Details

#to_dynamicObject



1373
1374
1375
1376
1377
1378
# File 'lib/schema.rb', line 1373

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

#to_json(options = nil) ⇒ Object



1380
1381
1382
# File 'lib/schema.rb', line 1380

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