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



544
545
546
547
548
549
550
551
# File 'lib/schemas.rb', line 544

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



553
554
555
# File 'lib/schemas.rb', line 553

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

Instance Method Details

#to_dynamicObject



557
558
559
560
561
562
563
# File 'lib/schemas.rb', line 557

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

#to_json(options = nil) ⇒ Object



565
566
567
# File 'lib/schemas.rb', line 565

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