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
1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 |
# File 'lib/schema.rb', line 1391 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
1402 1403 1404 |
# File 'lib/schema.rb', line 1402 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1406 1407 1408 1409 1410 1411 1412 |
# File 'lib/schema.rb', line 1406 def to_dynamic if !slack2.nil? slack2.to_dynamic elsif !string.nil? string end end |
#to_json(options = nil) ⇒ Object
1414 1415 1416 |
# File 'lib/schema.rb', line 1414 def to_json( = nil) JSON.generate(to_dynamic, ) end |