Class: Scrivito::ObjCollection
- Inherits:
-
Object
- Object
- Scrivito::ObjCollection
- Defined in:
- app/cms/scrivito/obj_collection.rb
Overview
This class allows you to retrieve CMS objects from a specific working copy. You can get an instance by accessing Workspace#objs.
Instance Method Summary collapse
-
#all ⇒ ObjSearchEnumerator
Returns an ObjSearchEnumerator of all Objs.
-
#find(id_or_list) ⇒ Obj+
Find an Obj by its id.
-
#find_all_by_obj_class(obj_class) ⇒ ObjSearchEnumerator
Returns an ObjSearchEnumerator of all Objs with the given
obj_class
. -
#find_by_path(path) ⇒ Scrivito::BasicObj, NilClass
Find the Obj that has the given
path
. -
#find_by_permalink(permalink) ⇒ Scrivito::BasicObj, NilClass
Returns the Obj that has the given
permalink
. -
#find_including_deleted(id_or_list) ⇒ Obj+
Find a Obj by its id.
-
#where(field, operator, value, boost = nil) ⇒ ObjSearchEnumerator
Returns an ObjSearchEnumerator with the given initial subquery consisting of the four arguments.
Instance Method Details
#all ⇒ ObjSearchEnumerator
Returns an Scrivito::ObjSearchEnumerator of all Objs.
89 90 91 |
# File 'app/cms/scrivito/obj_collection.rb', line 89 def all ObjSearchEnumerator.new(workspace, 1000) end |
#find(id_or_list) ⇒ Obj+
18 19 20 |
# File 'app/cms/scrivito/obj_collection.rb', line 18 def find(id_or_list) find_using(id_or_list, :find_by) end |
#find_all_by_obj_class(obj_class) ⇒ ObjSearchEnumerator
Returns an Scrivito::ObjSearchEnumerator of all Objs with the given obj_class
.
97 98 99 |
# File 'app/cms/scrivito/obj_collection.rb', line 97 def find_all_by_obj_class(obj_class) all.and(:_obj_class, :equals, obj_class) end |
#find_by_path(path) ⇒ Scrivito::BasicObj, NilClass
45 46 47 |
# File 'app/cms/scrivito/obj_collection.rb', line 45 def find_by_path(path) find_one_by(:path, path) end |
#find_by_permalink(permalink) ⇒ Scrivito::BasicObj, NilClass
62 63 64 |
# File 'app/cms/scrivito/obj_collection.rb', line 62 def find_by_permalink(permalink) find_one_by(:permalink, permalink) end |
#find_including_deleted(id_or_list) ⇒ Obj+
28 29 30 |
# File 'app/cms/scrivito/obj_collection.rb', line 28 def find_including_deleted(id_or_list) find_using(id_or_list, :find_by_including_deleted) end |
#where(field, operator, value, boost = nil) ⇒ ObjSearchEnumerator
Returns an Scrivito::ObjSearchEnumerator with the given initial subquery consisting of the four arguments.
Note that field
and value
may also be arrays for searching several fields or searching for several values.
Scrivito::ObjSearchEnumerators can be chained using one of the chainable methods (e.g. Scrivito::ObjSearchEnumerator#and and Scrivito::ObjSearchEnumerator#and_not).
81 82 83 84 |
# File 'app/cms/scrivito/obj_collection.rb', line 81 def where(field, operator, value, boost = nil) ObjSearchEnumerator.new(workspace) .and(field, operator, value, boost) end |