Class: Dry::Initializer::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/initializer/scope.rb

Overview

Shared scope for several params and options

Instance Method Summary collapse

Instance Method Details

#option(name, **options) ⇒ self

Defines option with shared settings

Parameters:

  • name (#to_sym)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :default (Object)

    The default value

  • :type (#call)

    The type constraings via dry-types

  • :reader (Boolean) — default: true

    Whether to define attr_reader

Returns:

  • (self)

    itself



20
21
22
# File 'lib/dry/initializer/scope.rb', line 20

def option(name, **options)
  @klass.option name, @options.merge(options)
end

#param(name, **options) ⇒ self

Defines param with shared settings

Parameters:

  • name (#to_sym)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :default (Object)

    The default value

  • :type (#call)

    The type constraings via dry-types

  • :reader (Boolean) — default: true

    Whether to define attr_reader

Returns:

  • (self)

    itself



10
11
12
# File 'lib/dry/initializer/scope.rb', line 10

def param(name, **options)
  @klass.param name, @options.merge(options)
end