Class: Plushie::Type::A11y::Spec
- Inherits:
-
Data
- Object
- Data
- Plushie::Type::A11y::Spec
- Defined in:
- lib/plushie/type/a11y.rb
Overview
Immutable spec; use #with to create modified copies.
Instance Method Summary collapse
-
#initialize(**fields) ⇒ Spec
constructor
A new instance of Spec.
-
#to_wire ⇒ Hash
Wire-ready map with nil fields stripped.
-
#with(**changes) ⇒ Object
Returns a copy with the given fields updated.
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_wire ⇒ Hash
Returns 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 |