Sha256: 6fa8f8da182e7f2302831ac560a9e79b24a3b484acd509f5ba84e36102be793a
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
module Dry # Declares arguments of the initializer (params and options) # # @api public # module Initializer require_relative "initializer/errors" require_relative "initializer/argument" require_relative "initializer/arguments" require_relative "initializer/builder" # Declares a plain argument # # @param [#to_sym] name # # @option options [Object] :default The default value # @option options [#call] :type The type constraings via `dry-types` # @option options [Boolean] :reader (true) Whether to define attr_reader # # @return [self] itself # def param(name, **options) arguments_builder.define_initializer(name, option: false, **options) self end # Declares a named argument # # @param (see #param) # @option (see #param) # @return (see #param) # def option(name, **options) arguments_builder.define_initializer(name, option: true, **options) self end private def arguments_builder @arguments_builder ||= begin builder = Builder.new include builder.mixin builder end end def inherited(klass) klass.instance_variable_set(:@arguments_builder, arguments_builder) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.0.1 | lib/dry/initializer.rb |