Class: Argon2ID

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



646
647
648
649
650
651
652
653
# File 'lib/schemas.rb', line 646

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    iterations:  d.fetch("iterations"),
    memory:      d.fetch("memory"),
    parallelism: d.fetch("parallelism"),
  )
end

.from_json!(json) ⇒ Object



655
656
657
# File 'lib/schemas.rb', line 655

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

Instance Method Details

#to_dynamicObject



659
660
661
662
663
664
665
# File 'lib/schemas.rb', line 659

def to_dynamic
  {
    "iterations"  => iterations,
    "memory"      => memory,
    "parallelism" => parallelism,
  }
end

#to_json(options = nil) ⇒ Object



667
668
669
# File 'lib/schemas.rb', line 667

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