class Versionomy::Conversion::Parsing::Builder

Call methods of this class in the block passed to Versionomy::Conversion::Parsing#new to fine-tune the behavior of the converter.

Public Instance Methods

to_generate_parse_params(&block_) click to toggle source

Provide a block that generates the params used to parse the new value. The block should take one parameter, the convert_params passed to convert_value (which may be nil). It should return the parse params that should be used.

# File lib/versionomy/conversion/parsing.rb, line 129
def to_generate_parse_params(&block_)
  @parse_params_generator = block_
end
to_modify_original_value(&block_) click to toggle source

Provide a block that can modify the original value prior to it being unparsed. The block should take two parameters: first, the original value to be converted, and second, the convert_params passed to convert_value (which may be nil). It should return the value to be unparsed, which may be the same as the value originally passed in. This method may fail-fast by raising a Versionomy::Errors::ConversionError if it determines that the value passed in cannot be converted as is.

# File lib/versionomy/conversion/parsing.rb, line 155
def to_modify_original_value(&block_)
  @original_value_modifier = block_
end
to_modify_string(&block_) click to toggle source

Provide a block that can modify the unparsed string prior to it being passed to the parser. The block should take two parameters: first, the string resulting from unparsing the old value, and second, the convert_params passed to convert_value (which may be nil). It should return the string to be parsed to get the new value.

# File lib/versionomy/conversion/parsing.rb, line 167
def to_modify_string(&block_)
  @string_modifier = block_
end
to_modify_unparse_params(&block_) click to toggle source

Provide a block that can modify the params used to unparse the old value. The block should take two parameters: first, the original unparse params from the old value (which may be nil), and second, the convert_params passed to convert_value (which may also be nil). It should return the unparse params that should actually be used.

# File lib/versionomy/conversion/parsing.rb, line 141
def to_modify_unparse_params(&block_)
  @unparse_params_modifier = block_
end