Class: Plushie::Type::A11y::Spec

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/type/a11y.rb

Overview

Immutable spec; use #with to create modified copies.

Instance Method Summary collapse

Constructor Details

#initialize(**fields) ⇒ Spec

Returns a new instance of Spec.



42
43
44
45
# File 'lib/plushie/type/a11y.rb', line 42

def initialize(**fields)
  defaults = FIELD_KEYS.each_with_object({}) { |k, h| h[k] = nil }
  super(**defaults.merge(fields))
end

Instance Method Details

#to_wireHash

Returns wire-ready map with nil fields stripped.

Returns:

  • (Hash)

    wire-ready map with nil fields stripped



53
54
55
# File 'lib/plushie/type/a11y.rb', line 53

def to_wire
  to_h.compact
end

#with(**changes) ⇒ Object

Returns a copy with the given fields updated.



48
49
50
# File 'lib/plushie/type/a11y.rb', line 48

def with(**changes)
  self.class.new(**to_h.merge(changes))
end