class Dry::Initializer::Definition
and build value of instance attribute.
Defines methods to add corresponding reader to the class,
Base class for parameter or option definitions
@abstract
@private
def ==(other)
def ==(other) other.instance_of?(self.class) && (other.source == source) end
def code
def code Builders::Reader[self] end
def inch
def inch @inch ||= (option ? "@option" : "@param ").tap do |text| text << " [Object]" text << (option ? " :#{source}" : " #{source}") text << (optional ? " (optional)" : " (required)") text << " #{desc}" if desc end end
def initialize(**options)
def initialize(**options) @option = options[:option] @null = options[:null] @source = options[:source] @target = options[:target] @ivar = "@#{@target}" @type = options[:type] @reader = options[:reader] @default = options[:default] @optional = options[:optional] @desc = options[:desc] end
def name
def name @name ||= "#{option ? "option" : "parameter"} '#{source}'" end
def options
def options { as: target, type:, optional:, default:, reader:, desc: }.compact end