class PagePart
   
  include Mongoid::Document
  include Mongoid::Timestamps

  field :name
  field :content, localize: true
  field :kind
  field :public_r_tag
  field :public_r_tag_object_id, :default => nil
  field :public_r_tag_option, :default => nil
  field :page_title, localize: true
  field :widget_path
  
  field :widget_style
  field :widget_field , :type => Array
  field :widget_data_count

  belongs_to :page
  belongs_to :module_app

  before_save :delete_empty_widget_field

  protected
  
  def delete_empty_widget_field
  	if self.widget_field
        self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) }
  	end
    # self.widget_field.delete("") if self.widget_field
  end

end