Class: CaTissue::ControlledValueFinder
- Inherits:
-
Object
- Object
- CaTissue::ControlledValueFinder
- Defined in:
- lib/catissue/database/controlled_value_finder.rb
Overview
Finds attribute controlled values.
Instance Method Summary collapse
-
#controlled_value(value) ⇒ Object
Returns the CV value for the given source value.
-
#initialize(attribute) ⇒ ControlledValueFinder
constructor
Creates a new ControlledValueFinder for the given attribute.
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.
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.
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 |