Class: Omnizip::Models::CompressionOptions

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/omnizip/models/compression_options.rb

Overview

Model representing compression operation options.

Serialized via lutaml-model — callers should not write hand-rolled to_h / to_json / from_json on this class. The framework provides #to_hash, #to_json, and .from_hash / .from_json automatically from the attribute declarations below.

Instance Method Summary collapse

Instance Method Details

#apply(attributes) ⇒ self

Apply a hash of attributes. Only keys declared as +attribute+s above are applied; unknown keys are silently ignored.

Parameters:

  • attributes (Hash{Symbol=>Object})

Returns:

  • (self)


39
40
41
42
43
44
45
# File 'lib/omnizip/models/compression_options.rb', line 39

def apply(attributes)
  self.class.attributes.each do |attr|
    name = attr.name
    public_send("#{name}=", attributes[name]) if attributes.key?(name)
  end
  self
end

#validate!Boolean

Validate that all set values are within their type's domain.

Returns:

  • (Boolean)

    true if valid

Raises:

  • (ArgumentError)

    if any value is invalid



51
52
53
54
55
# File 'lib/omnizip/models/compression_options.rb', line 51

def validate!
  raise ArgumentError, "level must be 0-9" unless (0..9).cover?(level)

  true
end