Module: Shared::IsData::Navigation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/shared/is_data/navigation.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #base_navigation_next ⇒ Object
- #base_navigation_previous ⇒ Object
- #next ⇒ Object
- #next_by_created_at ⇒ Object
- #next_by_user_created_at(user_id) ⇒ Object
- #previous ⇒ Object
- #previous_by_created_at ⇒ Object
- #previous_by_user_created_at(user_id) ⇒ Object
Instance Method Details
#base_navigation_next ⇒ Object
7 8 9 10 11 12 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 7 def base_class = self.class.base_class base = base_class.order(id: :ASC).where(base_class.arel_table[:id].gt(id)).limit(1) return base.where(project_id: project_id) if respond_to?(:project_id) base end |
#base_navigation_previous ⇒ Object
14 15 16 17 18 19 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 14 def base_class = self.class.base_class base = base_class.order(id: :DESC).where(base_class.arel_table[:id].lt(id)).limit(1) return base.where(project_id: project_id) if respond_to?(:project_id) base end |
#next ⇒ Object
21 22 23 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 21 def next .first end |
#next_by_created_at ⇒ Object
29 30 31 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 29 def next_by_created_at .reorder(created_at: :asc).first end |
#next_by_user_created_at(user_id) ⇒ Object
37 38 39 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 37 def next_by_user_created_at(user_id) .where(created_by_id: user_id).reorder(created_at: :asc).first end |
#previous ⇒ Object
25 26 27 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 25 def previous .first end |
#previous_by_created_at ⇒ Object
33 34 35 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 33 def previous_by_created_at .reorder(created_at: :desc).first end |
#previous_by_user_created_at(user_id) ⇒ Object
41 42 43 |
# File 'app/models/concerns/shared/is_data/navigation.rb', line 41 def previous_by_user_created_at(user_id) .where(created_by_id: user_id).reorder(created_at: :desc).first end |