Class: GlobalDomains

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



3248
3249
3250
3251
3252
3253
3254
3255
# File 'lib/schemas.rb', line 3248

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    domains:             d.fetch("domains"),
    excluded:            d.fetch("excluded"),
    global_domains_type: d.fetch("type"),
  )
end

.from_json!(json) ⇒ Object



3257
3258
3259
# File 'lib/schemas.rb', line 3257

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

Instance Method Details

#to_dynamicObject



3261
3262
3263
3264
3265
3266
3267
# File 'lib/schemas.rb', line 3261

def to_dynamic
  {
    "domains"  => domains,
    "excluded" => excluded,
    "type"     => global_domains_type,
  }
end

#to_json(options = nil) ⇒ Object



3269
3270
3271
# File 'lib/schemas.rb', line 3269

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