2010-08-24 22:59:22 +00:00
|
|
|
class EditableElement
|
|
|
|
|
|
|
|
include Mongoid::Document
|
|
|
|
|
|
|
|
## fields ##
|
2010-08-31 21:53:30 +00:00
|
|
|
# field :kind
|
2010-08-24 22:59:22 +00:00
|
|
|
field :slug
|
|
|
|
field :block
|
2010-08-31 21:53:30 +00:00
|
|
|
# field :content
|
2010-08-24 22:59:22 +00:00
|
|
|
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 ##
|
|
|
|
|
2010-08-31 21:53:30 +00:00
|
|
|
# def content
|
|
|
|
# self.read_attribute(:content).blank? ? self.default_content : self.read_attribute(:content)
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# def short_text?; self._type == 'EditableShortText'; end
|
|
|
|
#
|
|
|
|
# def long_text?; self._type == 'EditableLongText'; end
|
2010-08-29 23:41:44 +00:00
|
|
|
|
2010-08-24 22:59:22 +00:00
|
|
|
end
|