Sha256: 645f213ca88cff0cbe3c2bd497d3b59c58b6f96cab5d4ec50845450572c580ed

Contents?: true

Size: 877 Bytes

Versions: 18

Compression:

Stored size: 877 Bytes

Contents

class PreferenceType < ActiveRecord::Base
  attr_protected :created_at, :updated_at
  
  has_many_polymorphic :preferenced_records,
               :through => :valid_preference_types,
               :models => [:app_containers, :desktops, :organizers, :applications]

  has_many    :preferences
  belongs_to  :default_preference_option, :foreign_key => 'default_pref_option_id', :class_name => 'PreferenceOption'
  has_and_belongs_to_many :preference_options
  
  alias :options :preference_options
  alias :default_option :default_preference_option

  def options_hash
    Hash[*self.preference_options.collect { |v|[v.internal_identifier, v.value]}.flatten]
  end

  def self.iid( internal_identifier )
    where('internal_identifier = ?', internal_identifier.to_s).first
  end

  def default_value
    default_preference_option.value
  end
  
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
erp_app-4.0.0 app/models/preference_type.rb
erp_app-3.1.16 app/models/preference_type.rb
erp_app-3.1.15 app/models/preference_type.rb
erp_app-3.1.14 app/models/preference_type.rb
erp_app-3.1.13 app/models/preference_type.rb
erp_app-3.1.12 app/models/preference_type.rb
erp_app-3.1.11 app/models/preference_type.rb
erp_app-3.1.10 app/models/preference_type.rb
erp_app-3.1.9 app/models/preference_type.rb
erp_app-3.1.8 app/models/preference_type.rb
erp_app-3.1.7 app/models/preference_type.rb
erp_app-3.1.6 app/models/preference_type.rb
erp_app-3.1.5 app/models/preference_type.rb
erp_app-3.1.4 app/models/preference_type.rb
erp_app-3.1.3 app/models/preference_type.rb
erp_app-3.1.2 app/models/preference_type.rb
erp_app-3.1.1 app/models/preference_type.rb
erp_app-3.1.0 app/models/preference_type.rb