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

#optionsHash (readonly)

Returns:



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

def options
  @options
end

Instance Method Details

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



8
9
10
11
12
# File 'lib/dry/types/options.rb', line 8

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

#meta(data = nil) ⇒ Hash, Definition

Parameters:

  • data (Hash) (defaults to: nil)

Returns:



22
23
24
# File 'lib/dry/types/options.rb', line 22

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

#with(new_options) ⇒ Definition

Parameters:

  • new_options (Hash)

Returns:



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

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