Class: AMEE::DataAbstraction::Metadatum
- Defined in:
- lib/amee-data-abstraction/metadatum.rb
Overview
Subclass of Input
providing methods and attributes appropriate for representing arbitrary metadata which does not correspond to any AMEE profile item value or drill.
Constant Summary
Constants inherited from Term
Term::Interfaces, Term::UnitFields
Instance Attribute Summary
Attributes inherited from Input
Attributes inherited from Term
Instance Method Summary collapse
-
#compulsory?(usage = nil) ⇒ Boolean
Returns
false
as all metadatum are arbitrarily defined and therefore not directly involved in any AMEE calculation. -
#initialize(options = {}, &block) ⇒ Metadatum
constructor
Initialization of Metadatum objects follows that of the parent Input class.
-
#valid? ⇒ Boolean
Returns
true
if the value set forself
is valid.
Methods inherited from Input
#choice_validation_message, #choices, #clean!, #compulsory!, #dirty?, #disabled?, #fixed, #fixed?, #invalid, #optional!, #optional?, #options_for_select, #validate!, #validation, #validation_message, #value
Methods inherited from Term
#==, #after?, #before?, #convert_unit, convert_value_to_type, #disable!, #disabled?, #enable!, #enabled?, #has_numeric_value?, #hidden?, #hide!, #initialize_copy, #inspect, #interface, #is_numeric?, #note, #set?, #show!, #to_quantity, #to_s, #unset?, validate_dimensional_equivalence?, #value, #visible?
Constructor Details
#initialize(options = {}, &block) ⇒ Metadatum
Initialization of Metadatum objects follows that of the parent Input class. The interface
attribute of self
is set to :drop_down
by default, but can be manually configured if required.
20 21 22 23 |
# File 'lib/amee-data-abstraction/metadatum.rb', line 20 def initialize(={},&block) super interface :drop_down unless interface end |
Instance Method Details
#compulsory?(usage = nil) ⇒ Boolean
Returns false
as all metadatum are arbitrarily defined and therefore not directly involved in any AMEE calculation.
42 43 44 |
# File 'lib/amee-data-abstraction/metadatum.rb', line 42 def compulsory?(usage=nil) false end |
#valid? ⇒ Boolean
Returns true
if the value set for self
is valid. If self
contains neither a custom validation pattern nor any defined choices, true
is returned. Otherwise, validity depends on the custom validation being successful (if present) and the the value of self
matching one of the entries in the choices
attribute (if defined). Otherwise, returns false
.
53 54 55 |
# File 'lib/amee-data-abstraction/metadatum.rb', line 53 def valid? super && (choices.blank? || choices.include?(value)) end |