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

Instance Method Details

#base_navigation_nextObject



7
8
9
10
11
12
# File 'app/models/concerns/shared/is_data/navigation.rb', line 7

def base_navigation_next
  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_previousObject



14
15
16
17
18
19
# File 'app/models/concerns/shared/is_data/navigation.rb', line 14

def base_navigation_previous
  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

#nextObject



21
22
23
# File 'app/models/concerns/shared/is_data/navigation.rb', line 21

def next
  base_navigation_next.first
end

#next_by_created_atObject



29
30
31
# File 'app/models/concerns/shared/is_data/navigation.rb', line 29

def next_by_created_at
  base_navigation_next.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)
  base_navigation_next.where(created_by_id: user_id).reorder(created_at: :asc).first
end

#previousObject



25
26
27
# File 'app/models/concerns/shared/is_data/navigation.rb', line 25

def previous
  base_navigation_previous.first
end

#previous_by_created_atObject



33
34
35
# File 'app/models/concerns/shared/is_data/navigation.rb', line 33

def previous_by_created_at
  base_navigation_previous.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)
  base_navigation_previous.where(created_by_id: user_id).reorder(created_at: :desc).first
end