Class: Slack1

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



102
103
104
105
106
107
108
# File 'lib/schema.rb', line 102

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

.from_json!(json) ⇒ Object



110
111
112
# File 'lib/schema.rb', line 110

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

Instance Method Details

#to_dynamicObject



114
115
116
117
118
119
# File 'lib/schema.rb', line 114

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

#to_json(options = nil) ⇒ Object



121
122
123
# File 'lib/schema.rb', line 121

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