Class: CaTissue::ControlledValueFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/catissue/database/controlled_value_finder.rb

Overview

Finds attribute controlled values.

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ ControlledValueFinder

Creates a new ControlledValueFinder for the given attribute. The optional YAML properties file name maps input values to controlled values.

Parameters:

  • attribute (Symbol)

    the CV attribute



12
13
14
# File 'lib/catissue/database/controlled_value_finder.rb', line 12

def initialize(attribute)
  @attribute = attribute
end

Instance Method Details

#controlled_value(value) ⇒ Object

Returns the CV value for the given source value. A case-insensitive lookup is performed on the CV.

Parameters:

  • value (String, nil)

    the CV string value to find

Raises:

See Also:



22
23
24
25
26
# File 'lib/catissue/database/controlled_value_finder.rb', line 22

def controlled_value(value)
  return if value.blank?
  ControlledValues.instance.find(@attribute, value) or
    raise ControlledValueError.new("#{@attribute} value '#{value}' is not a recognized controlled value.")
end