Class: ConfigurationItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ConfigurationItem
- Defined in:
- app/models/configuration_item.rb
Instance Method Summary collapse
- #category ⇒ Object
- #clear_options ⇒ Object
- #set_options(internal_identifiers_or_value) ⇒ Object
- #to_js_hash ⇒ Object
Instance Method Details
#category ⇒ Object
12 13 14 |
# File 'app/models/configuration_item.rb', line 12 def category self.type.category end |
#clear_options ⇒ Object
23 24 25 26 27 |
# File 'app/models/configuration_item.rb', line 23 def self..each{|option|option.destroy} if self.configuration_item_type. self..destroy_all self.save end |
#set_options(internal_identifiers_or_value) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/configuration_item.rb', line 29 def (internal_identifiers_or_value) if self.configuration_item_type. value = internal_identifiers_or_value.first unless value.blank? self. << ConfigurationOption.create(:value => value, :user_defined => true) end elsif self.configuration_item_type.is_multi_optional? internal_identifiers_or_value.each do |value| self. << self.configuration_item_type.find_configuration_option(value) unless value.blank? end else value = internal_identifiers_or_value.first self. << self.configuration_item_type.find_configuration_option(internal_identifiers_or_value) unless value.blank? end self.save end |
#to_js_hash ⇒ Object
16 17 18 19 20 21 |
# File 'app/models/configuration_item.rb', line 16 def to_js_hash {:id => self.id, :configruationItemType => self.type.to_js_hash, :configurationOptions => .collect(&:to_js_hash) } end |