lib/scrivito/basic_obj.rb in scrivito_sdk-1.5.5 vs lib/scrivito/basic_obj.rb in scrivito_sdk-1.6.0.rc1

- old
+ new

@@ -50,13 +50,15 @@ _text_links ].freeze extend ActiveModel::Naming extend AttributeContent::ClassMethods + extend Associations::ClassMethods include AttributeContent include ModelIdentity + include Associations def self.type_computer @_type_computer ||= TypeComputer.new(Scrivito::BasicObj, ::Obj) end @@ -76,10 +78,12 @@ # @param [Hash] attributes of the new obj # @param [Hash] context in which the object is created # @option context [Scrivito::User] :scrivito_user current visitor # @return [Obj] the newly created {Scrivito::BasicObj Obj} # + # @raise [ArgumentError] if called on +Obj+ without +_obj_class+ attribute. + # # @see Scrivito::AttributeContent::ClassMethods#default_for # # @example Provide reference lists as an Array of {Scrivito::BasicObj Obj}. # Obj.create(:reference_list => [other_obj]) # @@ -214,10 +218,19 @@ # @example Look for all objects whose class is "Item". The path should start with a defined location. Furthermore, select only items of a particular category: # Obj.where(:_obj_class, :equals, 'Item').and(:_path, :starts_with, '/en/items/').select do |item| # item.categories.include?(category) # end # + # @example Find CMS objects linking to +my_image+ through any link or reference: + # Obj.where(:*, :links_to, my_image) + # + # @example Find +BlogPostPage+ objects linking to +my_image1+ or +my_image2+ through any link or reference: + # BlogPostPage.where(:*, :links_to, [my_img1, my_img2]) + # + # @example Find all objects of the +BlogPost+ class that reference +author_obj+ via the +authors+ referencelist attribute. + # BlogPost.where(:authors, :refers_to, author_obj) + # # @param [Symbol, String, Array<Symbol, String>] field See {Scrivito::ObjSearchEnumerator#and} # for details # @param [Symbol, String] operator See {Scrivito::ObjSearchEnumerator#and} for details # @param [String, Array<String>] value See {Scrivito::ObjSearchEnumerator#and} for details # @param [Hash] boost See {Scrivito::ObjSearchEnumerator#and} for details @@ -1154,11 +1167,11 @@ end class << self def assert_not_basic_obj(method_name) if self == Scrivito::BasicObj - raise ScrivitoError, "Can not call #{method_name} on Scrivito::BasicObj." - + " Only call it on Obj or subclasses of Obj" + raise ScrivitoError, "Can not call #{method_name} on Scrivito::BasicObj."\ + " Only call it on Obj or subclasses of Obj" end end # # Restores a previously deleted +Obj+.