Class: Collection

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



3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
# File 'lib/schemas.rb', line 3211

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    external_id:     d["externalId"],
    hide_passwords:  d.fetch("hidePasswords"),
    id:              d["id"],
    collection_name: d.fetch("name"),
    organization_id: d.fetch("organizationId"),
    read_only:       d.fetch("readOnly"),
  )
end

.from_json!(json) ⇒ Object



3223
3224
3225
# File 'lib/schemas.rb', line 3223

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

Instance Method Details

#to_dynamicObject



3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
# File 'lib/schemas.rb', line 3227

def to_dynamic
  {
    "externalId"     => external_id,
    "hidePasswords"  => hide_passwords,
    "id"             => id,
    "name"           => collection_name,
    "organizationId" => organization_id,
    "readOnly"       => read_only,
  }
end

#to_json(options = nil) ⇒ Object



3238
3239
3240
# File 'lib/schemas.rb', line 3238

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