Module: Dry::Types::Meta
- Included in:
- Composition, Nominal
- Defined in:
- lib/dry/types/meta.rb
Overview
Storage for meta-data
Instance Method Summary collapse
- #initialize(*args, meta: EMPTY_HASH, **options) ⇒ Object
- #meta(data = Undefined) ⇒ Object
-
#pristine ⇒ Dry::Types::Type
Resets meta.
- #with(**options) ⇒ Type
Instance Method Details
#initialize(*args, meta: EMPTY_HASH, **options) ⇒ Object
9 10 11 12 |
# File 'lib/dry/types/meta.rb', line 9 def initialize(*args, meta: EMPTY_HASH, **) super(*args, **) @meta = .freeze end |
#meta ⇒ Hash #meta(data) ⇒ Type
29 30 31 32 33 34 35 36 37 |
# File 'lib/dry/types/meta.rb', line 29 def (data = Undefined) if Undefined.equal?(data) @meta elsif data.empty? self else with(meta: @meta.merge(data)) end end |
#pristine ⇒ Dry::Types::Type
Resets meta
44 |
# File 'lib/dry/types/meta.rb', line 44 def pristine = with(meta: EMPTY_HASH) |
#with(**options) ⇒ Type
19 |
# File 'lib/dry/types/meta.rb', line 19 def with(**) = super(meta: @meta, **) |