Class: PasswordHistory

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



3047
3048
3049
3050
3051
3052
3053
# File 'lib/schemas.rb', line 3047

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    last_used_date: d.fetch("lastUsedDate"),
    password:       d.fetch("password"),
  )
end

.from_json!(json) ⇒ Object



3055
3056
3057
# File 'lib/schemas.rb', line 3055

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

Instance Method Details

#to_dynamicObject



3059
3060
3061
3062
3063
3064
# File 'lib/schemas.rb', line 3059

def to_dynamic
  {
    "lastUsedDate" => last_used_date,
    "password"     => password,
  }
end

#to_json(options = nil) ⇒ Object



3066
3067
3068
# File 'lib/schemas.rb', line 3066

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