Class: ResponseForString

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



2547
2548
2549
2550
2551
2552
2553
2554
# File 'lib/schemas.rb', line 2547

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    data:          d["data"],
    error_message: d["errorMessage"],
    success:       d.fetch("success"),
  )
end

.from_json!(json) ⇒ Object



2556
2557
2558
# File 'lib/schemas.rb', line 2556

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

Instance Method Details

#to_dynamicObject



2560
2561
2562
2563
2564
2565
2566
# File 'lib/schemas.rb', line 2560

def to_dynamic
  {
    "data"         => data,
    "errorMessage" => error_message,
    "success"      => success,
  }
end

#to_json(options = nil) ⇒ Object



2568
2569
2570
# File 'lib/schemas.rb', line 2568

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