Class: Reaction::ParamBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/reaction/param_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type_builder = nil, validator_builders = []) ⇒ ParamBuilder

Returns a new instance of ParamBuilder.



7
8
9
10
11
# File 'lib/reaction/param_builder.rb', line 7

def initialize(name, type_builder = nil, validator_builders = [])
  @name = name
  @type_builder = type_builder
  @validator_builders = validator_builders
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/reaction/param_builder.rb', line 3

def name
  @name
end

#type_builderObject

Returns the value of attribute type_builder.



4
5
6
# File 'lib/reaction/param_builder.rb', line 4

def type_builder
  @type_builder
end

#validator_buildersObject

Returns the value of attribute validator_builders.



5
6
7
# File 'lib/reaction/param_builder.rb', line 5

def validator_builders
  @validator_builders
end

Instance Method Details

#build(action, raw_value, provided = true) ⇒ Object



13
14
15
16
17
# File 'lib/reaction/param_builder.rb', line 13

def build(action, raw_value, provided = true)
  type = type_builder.build(action)
  validators = validator_builders.map{ |vb| vb.build(action) }
  Param.new(action, type, validators, name, raw_value, provided)
end