Class: AttributeType

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/attribute_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_iid_with_description(description) ⇒ Object



24
25
26
27
# File 'app/models/attribute_type.rb', line 24

def self.find_by_iid_with_description(description)
  iid = description.strip.underscore.gsub(/\s+/,"_")
  AttributeType.find_by_internal_identifier iid
end

Instance Method Details

#update_iidObject



29
30
31
# File 'app/models/attribute_type.rb', line 29

def update_iid
  self.internal_identifier = self.description.strip.underscore.gsub(/\s+/,"_")
end

#values_by_date_range(start_date, end_date) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/attribute_type.rb', line 11

def values_by_date_range(start_date, end_date)
  raise "attribute_type does not have a data_type of Date" unless self.data_type == "Date"
  
  attribute_values = self.attribute_values
  attribute_values.each do |attribute_value|
    unless attribute_value.value_as_date >= start_date and attribute_value.value_as_date <= end_date
      attribute_values.delete(attribute_value)
    end
  end

  attribute_values
end