Class: CacheClass

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



678
679
680
681
682
683
684
685
# File 'lib/schema.rb', line 678

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    cache_name: d["name"],
    paths: d.fetch("paths"),
    size: d["size"]
  )
end

.from_json!(json) ⇒ Object



687
688
689
# File 'lib/schema.rb', line 687

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

Instance Method Details

#to_dynamicObject



691
692
693
694
695
696
697
# File 'lib/schema.rb', line 691

def to_dynamic
  {
    "name" => cache_name,
    "paths" => paths,
    "size" => size
  }
end

#to_json(options = nil) ⇒ Object



699
700
701
# File 'lib/schema.rb', line 699

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