lib/scrivito/basic_obj.rb in scrivito_sdk-0.14.0 vs lib/scrivito/basic_obj.rb in scrivito_sdk-0.15.0

- old
+ new

@@ -468,32 +468,26 @@ def self.sort_by_list(objs_to_be_sorted, list) (list & objs_to_be_sorted) + (objs_to_be_sorted - list).sort_by(&:id) end # This should be a SET, because it's faster in this particular case. - OLD_INTERNAL_KEYS = Set.new(%w[ + INTERNAL_KEYS = Set.new(%w[ body - id - last_changed - name - obj_class_name - path - permalink - text_links + _id + _last_changed + _path + _permalink title ]) # Returns the value of an internal or external attribute specified by its name. # Passing an invalid key will not raise an error, but return +nil+. # @api public def [](key) key = key.to_s - if OLD_INTERNAL_KEYS.include?(key) - send(key) - elsif key.start_with?('_') && OLD_INTERNAL_KEYS.include?(internal_key = key[1..-1]) - # For backwards compatibility reasons - send(internal_key) + if INTERNAL_KEYS.include?(key) + read_attribute(key) else super end end @@ -526,24 +520,30 @@ def last_changed read_attribute('_last_changed') end def new?(revision=Workspace.current.base_revision) + return false unless revision + if read_attribute('_modification') != 'deleted' cms_data_for_revision(revision).nil? else false end end def deleted?(revision=Workspace.current.base_revision) + return false unless revision + if read_attribute('_modification') == 'deleted' cms_data_for_revision(revision).present? end end def modification(revision=Workspace.current.base_revision) + return Modification::UNMODIFIED unless revision + obj_data_from_revision = cms_data_for_revision(revision) if deleted?(revision) Modification::DELETED elsif new?(revision) @@ -606,10 +606,10 @@ # @api public def body if binary? nil else - StringTagging.tag_as_html(read_attribute('body')) + read_attribute('body') end end # for binary Objs body_length equals the file size # for non-binary Objs body_length equals the number of characters in the body (main content)