Class: Ortfodb::LocalizedContent
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Ortfodb::LocalizedContent
- Defined in:
- lib/ortfodb/database.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
283 284 285 286 287 288 289 290 291 292 |
# File 'lib/ortfodb/database.rb', line 283 def self.from_dynamic!(d) d = Types::Hash[d] new( abbreviations: Types::Hash[d.fetch("abbreviations")].map { |k, v| [k, Types::String[v]] }.to_h, blocks: d.fetch("blocks").map { |x| ContentBlock.from_dynamic!(x) }, footnotes: Types::Hash[d.fetch("footnotes")].map { |k, v| [k, Types::String[v]] }.to_h, layout: d.fetch("layout"), title: d.fetch("title"), ) end |
.from_json!(json) ⇒ Object
294 295 296 |
# File 'lib/ortfodb/database.rb', line 294 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
298 299 300 301 302 303 304 305 306 |
# File 'lib/ortfodb/database.rb', line 298 def to_dynamic { "abbreviations" => abbreviations, "blocks" => blocks.map { |x| x.to_dynamic }, "footnotes" => footnotes, "layout" => layout, "title" => title, } end |
#to_json(options = nil) ⇒ Object
308 309 310 |
# File 'lib/ortfodb/database.rb', line 308 def to_json( = nil) JSON.generate(to_dynamic, ) end |