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
31 32 33 34 35 36 37 38 39 |
# File 'lib/dry/types/meta.rb', line 31 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
46 47 48 |
# File 'lib/dry/types/meta.rb', line 46 def pristine with(meta: EMPTY_HASH) end |
#with(**options) ⇒ Type
19 20 21 |
# File 'lib/dry/types/meta.rb', line 19 def with(**) super(meta: @meta, **) end |