Class: SetSlice
- Inherits:
-
Slice
show all
- Includes:
- Mongoid::Document
- Defined in:
- app/models/set_slice.rb
Constant Summary
collapse
- DEFAULT_SORT_FIELD =
:created_at
- DEFAULT_SORT_DIRECTION =
:desc
Instance Attribute Summary
Attributes inherited from Slice
#current_page, #renderer
Instance Method Summary
collapse
Methods inherited from Slice
#as_json, #client_id?, #id_or_client_id, #normal_or_set_page, #reference, #render, restricted?, restricted_slice, #search_text, #setup, #template_path, #to_delete?, #type
#alone_in_adjacent_of_type?, #alone_in_container?, #first_adjacent_of_type?, #first_in_container?, #last_adjacent_of_type?, #last_in_container?, #next_slice, #peers, #position_in_adjacent_of_type, #position_in_container, #previous_slice
Instance Method Details
#addable_entries? ⇒ Boolean
15
16
17
|
# File 'app/models/set_slice.rb', line 15
def addable_entries?
true
end
|
#editable_entries? ⇒ Boolean
19
20
21
|
# File 'app/models/set_slice.rb', line 19
def editable_entries?
true
end
|
#entries ⇒ Object
27
28
29
|
# File 'app/models/set_slice.rb', line 27
def entries
sorted selected_by_type normal_or_set_page.children
end
|
#entry_type ⇒ Object
23
24
25
|
# File 'app/models/set_slice.rb', line 23
def entry_type
self.class.name.sub('SetSlice', '').underscore.to_sym
end
|
#page_entries(params = {}) ⇒ Object
31
32
33
|
# File 'app/models/set_slice.rb', line 31
def page_entries(params = {})
entries.paginate(paginate_options(params))
end
|
#paginate_options(params) ⇒ Object
35
36
37
|
# File 'app/models/set_slice.rb', line 35
def paginate_options(params)
params.reverse_merge(page: @page_num, per_page: per_page)
end
|
#prepare(params) ⇒ Object
11
12
13
|
# File 'app/models/set_slice.rb', line 11
def prepare(params)
@page_num = params[:page] || 1
end
|
#sort_direction ⇒ Object
43
44
45
|
# File 'app/models/set_slice.rb', line 43
def sort_direction
read_attribute(:sort_direction) || DEFAULT_SORT_DIRECTION
end
|
#sort_field ⇒ Object
39
40
41
|
# File 'app/models/set_slice.rb', line 39
def sort_field
read_attribute(:sort_field) || DEFAULT_SORT_FIELD
end
|