Sha256: 0e97813a5610056e9f27c4910f5de5e4ec5404b7ad61fe3efd4a9405f3d105e4

Contents?: true

Size: 674 Bytes

Versions: 5

Compression:

Stored size: 674 Bytes

Contents

class ContentInstance

  include Mongoid::Document
  include Mongoid::Timestamps
  
  ## fields (dynamic fields) ##
  field :_position_in_list, :type => Integer, :default => 0
  
  ## validations ##
  validate :require_highlighted_field
  
  ## associations ##
  embedded_in :content_type, :inverse_of => :contents
  
  ## named scopes ##
  named_scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
  
  ## methods ##
  
  protected
  
  def require_highlighted_field
    _alias = self.content_type.highlighted_field._alias.to_sym
    if self.send(_alias).blank?
      self.errors.add(_alias, :blank)
    end
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-0.0.1.4 app/models/content_instance.rb
locomotive_cms-0.0.1.3 app/models/content_instance.rb
locomotive_cms-0.0.1.2 app/models/content_instance.rb
locomotive_cms-0.0.1.1 app/models/content_instance.rb
locomotive_cms-0.0.1 app/models/content_instance.rb