Class: ParamsReady::Parameter::HashSetParameterBuilder

Inherits:
Builder show all
Includes:
Marshaller::BuilderModule
Defined in:
lib/params_ready/parameter/hash_set_parameter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Marshaller::BuilderModule

#marshal

Methods inherited from Builder

#helper

Methods inherited from AbstractBuilder

#build, define_parameter, define_registered_parameter, #fetch, #include, #initialize, #open?, register

Methods included from Extensions::Registry

#human_string, #registry

Constructor Details

This class inherits a constructor from ParamsReady::AbstractBuilder

Class Method Details

.instance(name, altn: nil, type: :boolean) ⇒ Object



39
40
41
# File 'lib/params_ready/parameter/hash_set_parameter.rb', line 39

def self.instance(name, altn: nil, type: :boolean)
  new HashSetParameterDefinition.new(name, altn: altn, type: type)
end

.resolve(type, input, *args, **opts, &block) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/params_ready/parameter/hash_set_parameter.rb', line 50

def self.resolve(type, input, *args, **opts, &block)
  if input.is_a? AbstractDefinition
    input
  else
    define_registered_parameter(type, input, *args, **opts, &block)
  end
end

Instance Method Details

#add(input, *args, val: nil, **opts, &block) ⇒ Object



43
44
45
46
47
# File 'lib/params_ready/parameter/hash_set_parameter.rb', line 43

def add(input, *args, val: nil, **opts, &block)
  type = @definition.type
  definition = self.class.resolve(type, input, *args, **opts, &block)
  @definition.add_child definition, value: val
end