Module: Dry::Types::Options

Included in:
Decorator, Definition, Sum
Defined in:
lib/dry/types/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/dry/types/options.rb', line 4

def options
  @options
end

Instance Method Details

#initialize(*args, **options) ⇒ Object



6
7
8
9
10
# File 'lib/dry/types/options.rb', line 6

def initialize(*args, **options)
  @__args__ = args
  @options = options
  @meta = options.fetch(:meta, {})
end

#meta(data = nil) ⇒ Object



16
17
18
# File 'lib/dry/types/options.rb', line 16

def meta(data = nil)
  data ? with(meta: @meta.merge(data)) : @meta
end

#with(new_options) ⇒ Object



12
13
14
# File 'lib/dry/types/options.rb', line 12

def with(new_options)
  self.class.new(*@__args__, options.merge(new_options))
end