class AMEE::DataAbstraction::Profile

Subclass of Input providing methods and attributes appropriate for representing AMEE profile item values specifically

Public Class Methods

new(options={},&block) click to toggle source

Initialization of Input objects follows that of the parent Term class. The interface attribute of self is set to :drop_down by default if a list of choices is defined using the choices attribute. Otherwise the interface attribute is set to :test_box, but can be manually configured if required.

Calls superclass method AMEE::DataAbstraction::Input::new
# File lib/amee-data-abstraction/profile.rb, line 35
def initialize(options={},&block)
  super
  interface :drop_down unless choices.blank?
  choice_validation_message unless choices.blank?
  interface :text_box unless interface
end

Public Instance Methods

amee_ivd() click to toggle source

Return the AMEE::Admin::ItemValueDefinition object associated with self.

# File lib/amee-data-abstraction/profile.rb, line 92
def amee_ivd
  parent.amee_ivds.detect{|x|x.path==path}
end
compulsory?(usage=nil) click to toggle source

Return true if the value of self is required before the parent calculation can be calculated. Otherwise, return false.

If no argument is provided, compulsory status is determined according to the current usage of the parent calculation. Compulsory status can be determined for a specific usage by passing in the usage path as an argument

# File lib/amee-data-abstraction/profile.rb, line 61
def compulsory?(usage=nil)
  usage||=parent.current_usage
  usage ? amee_ivd.compulsory?(usage) : super()
end
in_use?(usage) click to toggle source

Return true if the value of self is either compulsory OR optional in the owning calculation, i.e. is NOT forbidden.

If no argument is provided, the optional/compulsory status is defined according to the current usage of the parent caluclation. Otherwise, optional/compulsory status is determined on the basis of the usage whose AMEE platform path matches usage

# File lib/amee-data-abstraction/profile.rb, line 74
def in_use?(usage)
  compulsory?(usage)||optional?(usage)
end
optional?(usage=nil) click to toggle source

Return true if the value of self is NOT required before the parent calculation can be calculated. Otherwise, return false.

If no argument is provided, optional status is determined according to the current usage of the parent calculation. Optionality can be determined for a specific usage by passing in the usage path as an argument

Calls superclass method AMEE::DataAbstraction::Input#optional?
# File lib/amee-data-abstraction/profile.rb, line 49
def optional?(usage=nil)
  usage||=parent.current_usage
  usage ? amee_ivd.optional?(usage) : super()
end
out_of_use?(usage) click to toggle source

Return true if the value of self is neither compulsory OR optional in the owning calculation, i.e. is forbidden.

If no argument is provided, forbbiden status is defined according to the current usage of the parent caluclation. Otherwise, it is determined on the basis of the usage whose AMEE platform path matches usage

# File lib/amee-data-abstraction/profile.rb, line 85
def out_of_use?(usage)
  !in_use?(usage)
end
valid?() click to toggle source

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.

Calls superclass method AMEE::DataAbstraction::Input#valid?
# File lib/amee-data-abstraction/profile.rb, line 103
def valid?
  super && (choices.blank? || choices.include?(value))
end