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



2999
3000
3001
3002
3003
3004
3005
3006
# File 'lib/schemas.rb', line 2999

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



3008
3009
3010
# File 'lib/schemas.rb', line 3008

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

Instance Method Details

#to_dynamicObject



3012
3013
3014
3015
3016
3017
3018
# File 'lib/schemas.rb', line 3012

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

#to_json(options = nil) ⇒ Object



3020
3021
3022
# File 'lib/schemas.rb', line 3020

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