Class: Ortfodb::ExtractColorsConfiguration

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/ortfodb/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/ortfodb/configuration.rb', line 30

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    default_files: d.fetch("default files"),
    enabled:       d.fetch("enabled"),
    extract:       d.fetch("extract"),
  )
end

.from_json!(json) ⇒ Object



39
40
41
# File 'lib/ortfodb/configuration.rb', line 39

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

Instance Method Details

#to_dynamicObject



43
44
45
46
47
48
49
# File 'lib/ortfodb/configuration.rb', line 43

def to_dynamic
  {
    "default files" => default_files,
    "enabled"       => enabled,
    "extract"       => extract,
  }
end

#to_json(options = nil) ⇒ Object



51
52
53
# File 'lib/ortfodb/configuration.rb', line 51

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