Class: Trestle::Resource::Collection
- Inherits:
-
Object
- Object
- Trestle::Resource::Collection
- Defined in:
- lib/trestle/resource/collection.rb
Instance Method Summary collapse
- #decorate? ⇒ Boolean
- #finalize? ⇒ Boolean
-
#initialize(admin, options = {}) ⇒ Collection
constructor
A new instance of Collection.
- #paginate? ⇒ Boolean
- #prepare(params) ⇒ Object
- #scope? ⇒ Boolean
- #sort? ⇒ Boolean
Constructor Details
#initialize(admin, options = {}) ⇒ Collection
Returns a new instance of Collection.
7 8 9 |
# File 'lib/trestle/resource/collection.rb', line 7 def initialize(admin, ={}) @admin, @options = admin, end |
Instance Method Details
#decorate? ⇒ Boolean
37 38 39 |
# File 'lib/trestle/resource/collection.rb', line 37 def decorate? @options[:decorate] != false end |
#finalize? ⇒ Boolean
33 34 35 |
# File 'lib/trestle/resource/collection.rb', line 33 def finalize? @options[:finalize] != false end |
#paginate? ⇒ Boolean
29 30 31 |
# File 'lib/trestle/resource/collection.rb', line 29 def paginate? @options[:paginate] != false end |
#prepare(params) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/trestle/resource/collection.rb', line 11 def prepare(params) collection = collection(params) collection = apply_scopes(collection, params) if scope? collection = apply_sorting(collection, params) if sort? collection = paginate(collection, params) if paginate? collection = finalize_collection(collection) if finalize? collection = decorate_collection(collection) if decorate? collection end |
#scope? ⇒ Boolean
21 22 23 |
# File 'lib/trestle/resource/collection.rb', line 21 def scope? @options[:scope] != false end |
#sort? ⇒ Boolean
25 26 27 |
# File 'lib/trestle/resource/collection.rb', line 25 def sort? @options[:sort] != false end |