Module: Dry::Types::Options
- Included in:
- Decorator, Definition, Sum
- Defined in:
- lib/dry/types/options.rb
Instance Attribute Summary collapse
- #options ⇒ Hash readonly
Instance Method Summary collapse
- #initialize(*args, meta: EMPTY_HASH, **options) ⇒ Object
- #meta(data = nil) ⇒ Object
-
#pristine ⇒ Dry::Types::Type
Resets meta.
- #with(new_options) ⇒ Type
Instance Attribute Details
Instance Method Details
#initialize(*args, meta: EMPTY_HASH, **options) ⇒ Object
8 9 10 11 12 |
# File 'lib/dry/types/options.rb', line 8 def initialize(*args, meta: EMPTY_HASH, **) @__args__ = args @options = @meta = end |
#meta ⇒ Hash #meta(data) ⇒ Type
26 27 28 29 30 31 32 33 34 |
# File 'lib/dry/types/options.rb', line 26 def (data = nil) if !data @meta elsif data.empty? self else with(meta: @meta.merge(data)) end end |
#pristine ⇒ Dry::Types::Type
Resets meta
38 39 40 |
# File 'lib/dry/types/options.rb', line 38 def pristine with(meta: EMPTY_HASH) end |
#with(new_options) ⇒ Type
16 17 18 |
# File 'lib/dry/types/options.rb', line 16 def with() self.class.new(*@__args__, **, meta: @meta, **) end |