Class: Slack3

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



1901
1902
1903
1904
1905
1906
1907
# File 'lib/schema.rb', line 1901

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

.from_json!(json) ⇒ Object



1909
1910
1911
# File 'lib/schema.rb', line 1909

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

Instance Method Details

#to_dynamicObject



1913
1914
1915
1916
1917
1918
# File 'lib/schema.rb', line 1913

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

#to_json(options = nil) ⇒ Object



1920
1921
1922
# File 'lib/schema.rb', line 1920

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