2010-08-24 22:59:22 +00:00
|
|
|
class EditableElement
|
|
|
|
|
|
|
|
include Mongoid::Document
|
|
|
|
|
|
|
|
## fields ##
|
|
|
|
field :slug
|
|
|
|
field :block
|
|
|
|
field :content
|
|
|
|
field :default_content
|
|
|
|
field :hint
|
|
|
|
field :disabled, :type => Boolean, :default => false
|
2010-08-27 15:40:03 +00:00
|
|
|
field :from_parent, :type => Boolean, :default => false
|
2010-08-24 22:59:22 +00:00
|
|
|
|
|
|
|
## associations ##
|
|
|
|
embedded_in :page, :inverse_of => :editable_elements
|
|
|
|
|
|
|
|
## validations ##
|
|
|
|
validates_presence_of :slug
|
|
|
|
|
|
|
|
## methods ##
|
|
|
|
|
|
|
|
def content
|
|
|
|
self.read_attribute(:content).blank? ? self.default_content : self.read_attribute(:content)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|