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



1903
1904
1905
1906
1907
1908
1909
# File 'lib/schema.rb', line 1903

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

.from_json!(json) ⇒ Object



1911
1912
1913
# File 'lib/schema.rb', line 1911

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

Instance Method Details

#to_dynamicObject



1915
1916
1917
1918
1919
1920
# File 'lib/schema.rb', line 1915

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

#to_json(options = nil) ⇒ Object



1922
1923
1924
# File 'lib/schema.rb', line 1922

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