Class: Slack5
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Slack5
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 |
# File 'lib/schema.rb', line 1389 def self.from_dynamic!(d) begin value = Slack2.from_dynamic!(d) return new(slack2: value, string: nil) if schema[:slack2].right.valid? value rescue StandardError end return new(string: d, slack2: nil) if schema[:string].right.valid? d raise "Invalid union" end |
.from_json!(json) ⇒ Object
1400 1401 1402 |
# File 'lib/schema.rb', line 1400 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1404 1405 1406 1407 1408 1409 1410 |
# File 'lib/schema.rb', line 1404 def to_dynamic if !slack2.nil? slack2.to_dynamic elsif !string.nil? string end end |
#to_json(options = nil) ⇒ Object
1412 1413 1414 |
# File 'lib/schema.rb', line 1412 def to_json( = nil) JSON.generate(to_dynamic, ) end |