Class: Ortfodb::Work
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Ortfodb::Work
- Defined in:
- lib/ortfodb/database.rb
Overview
Work represents a given work in the database.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/ortfodb/database.rb', line 410 def self.from_dynamic!(d) d = Types::Hash[d] new( built_at: d.fetch("builtAt"), content: Types::Hash[d.fetch("content")].map { |k, v| [k, LocalizedContent.from_dynamic!(v)] }.to_h, description_hash: d.fetch("descriptionHash"), id: d.fetch("id"), metadata: WorkMetadata.from_dynamic!(d.fetch("metadata")), partial: d.fetch("Partial"), ) end |
.from_json!(json) ⇒ Object
422 423 424 |
# File 'lib/ortfodb/database.rb', line 422 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
426 427 428 429 430 431 432 433 434 435 |
# File 'lib/ortfodb/database.rb', line 426 def to_dynamic { "builtAt" => built_at, "content" => content.map { |k, v| [k, v.to_dynamic] }.to_h, "descriptionHash" => description_hash, "id" => id, "metadata" => .to_dynamic, "Partial" => partial, } end |
#to_json(options = nil) ⇒ Object
437 438 439 |
# File 'lib/ortfodb/database.rb', line 437 def to_json( = nil) JSON.generate(to_dynamic, ) end |