26 lines
		
	
	
		
			641 B
		
	
	
	
		
			Ruby
		
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			641 B
		
	
	
	
		
			Ruby
		
	
	
	
| class Attribute
 | |
|   
 | |
|   include Mongoid::Document
 | |
|   include Mongoid::Timestamps
 | |
|   
 | |
|   field :key
 | |
|   field :built_in, :type => Boolean, :default => false
 | |
|   field :disabled, :type => Boolean, :default => false
 | |
|   
 | |
|   has_many :attribute_fields, :autosave => true, :dependent => :destroy
 | |
|   has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
 | |
|   accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
 | |
|   
 | |
|   def is_built_in?
 | |
|     self.built_in
 | |
|   end
 | |
|   
 | |
|   def is_disabled?
 | |
|     self.disabled
 | |
|   end
 | |
|   
 | |
|   def get_enabled_attribute_fields
 | |
|     self.attribute_fields.excludes('disabled' => true)
 | |
|   end
 | |
|   
 | |
| end |