class SubPart
  include Mongoid::Document
  include Mongoid::Timestamps

	field :module
	field :title, localize: true
	field :widget_type
	field :widget_method
	field :kind, default: "none"
	field :content, localize: true
	field :data_count, type: Integer, default: 10
	field :categories, type: Array, :default => []
  field :tags, type: Array, :default => []
	field :custom_string_field, type: String
	field :custom_array_field, type: Array, :default => []

  belongs_to :page_part
  belongs_to :mobile_page_part

  	after_save :clear_cache
  	after_destroy :clear_cache

  	def clear_cache
  		Rails.cache.delete_matched( /#{self.id.to_s}/ )
  	end
end