class Dry::Configurable::DSL::Args

@api private

Attributes

args[R]

@api private

opts[R]

@api private

size[R]

@api private

Public Class Methods

new(args) click to toggle source

@api private

# File lib/dry/configurable/dsl/args.rb, line 21
def initialize(args)
  @args = args
  @size = args.size
  @opts = Setting::OPTIONS
end

Public Instance Methods

default() click to toggle source

@api private

# File lib/dry/configurable/dsl/args.rb, line 41
def default
  if size.equal?(1) && options.nil?
    args[0]
  elsif size > 1 && options
    args[0]
  else
    Undefined
  end
end
ensure_valid_options() click to toggle source

@api private

# File lib/dry/configurable/dsl/args.rb, line 28
def ensure_valid_options
  return unless options

  keys = options.keys - opts
  raise ArgumentError, "Invalid options: #{keys.inspect}" unless keys.empty?
end
options() click to toggle source

@api private

# File lib/dry/configurable/dsl/args.rb, line 52
def options
  args.detect { |arg| arg.is_a?(Hash) && (opts & arg.keys).any? }
end
to_ary() click to toggle source

@api private

# File lib/dry/configurable/dsl/args.rb, line 36
def to_ary
  [default, options || EMPTY_HASH]
end