• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MushroomObserver / mushroom-observer / 14145714091

29 Mar 2025 12:39PM UTC coverage: 84.27% (-9.7%) from 93.985%
14145714091

Pull #2808

github

web-flow
Merge 0843c72fa into 6655216a6
Pull Request #2808: Convert Query to AR scopes

472 of 2300 new or added lines in 78 files covered. (20.52%)

1381 existing lines in 27 files now uncovered.

26557 of 31514 relevant lines covered (84.27%)

537.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/classes/query/modules/sequence_operators.rb
1
# frozen_string_literal: true
2

3
# methods for moving forward/back up/down in Query results
UNCOV
4
module Query::Modules::SequenceOperators
×
5
  # Current place in results, as an id.  (Returns nil if not set yet.)
UNCOV
6
  attr_reader :current_id
×
7

8
  # Set current place in results; takes id (String or Integer).
UNCOV
9
  def current_id=(id)
×
UNCOV
10
    @save_current_id = @current_id = id.to_s.to_i
×
UNCOV
11
  end
×
12

13
  # Reset current place in results to place last given in a "current=" call.
UNCOV
14
  def reset
×
UNCOV
15
    @current_id = @save_current_id
×
UNCOV
16
  end
×
17

18
  # Current place in results, instantiated.  (Returns nil if not set yet.)
UNCOV
19
  def current(*)
×
UNCOV
20
    @current_id ? instantiate_results([@current_id], *).first : nil
×
UNCOV
21
  end
×
22

23
  # Set current place in results; takes instance or id (String or Integer).
UNCOV
24
  def current=(arg)
×
UNCOV
25
    if arg.is_a?(model)
×
UNCOV
26
      @results ||= {}
×
UNCOV
27
      @results[arg.id] = arg
×
UNCOV
28
      self.current_id = arg.id
×
UNCOV
29
    else
×
UNCOV
30
      self.current_id = arg
×
UNCOV
31
    end
×
UNCOV
32
  end
×
33

34
  # Move to first place.
UNCOV
35
  def first
×
UNCOV
36
    new_self = self
×
UNCOV
37
    id = new_self.select_value(limit: "1").to_i
×
UNCOV
38
    if id.positive?
×
UNCOV
39
      @current_id = id
×
UNCOV
40
    else
×
41
      new_self = nil
×
UNCOV
42
    end
×
UNCOV
43
    new_self
×
UNCOV
44
  end
×
45

46
  # Move to previous place.
UNCOV
47
  def prev
×
UNCOV
48
    new_self = self
×
UNCOV
49
    index = result_ids.index(current_id)
×
UNCOV
50
    return nil unless index
×
51

UNCOV
52
    if index.positive?
×
UNCOV
53
      @current_id = result_ids[index - 1]
×
UNCOV
54
    else
×
UNCOV
55
      new_self = nil
×
UNCOV
56
    end
×
UNCOV
57
    new_self
×
UNCOV
58
  end
×
59

60
  # Move to next place.
UNCOV
61
  def next
×
UNCOV
62
    new_self = self
×
UNCOV
63
    index = result_ids.index(current_id)
×
UNCOV
64
    return nil unless index
×
65

UNCOV
66
    if index < result_ids.length - 1
×
UNCOV
67
      @current_id = result_ids[index + 1]
×
UNCOV
68
    else
×
UNCOV
69
      new_self = nil
×
UNCOV
70
    end
×
UNCOV
71
    new_self
×
UNCOV
72
  end
×
73

74
  # Move to last place.
UNCOV
75
  def last
×
UNCOV
76
    new_self = self
×
UNCOV
77
    id = new_self.select_value(order: :reverse, limit: "1").to_i
×
UNCOV
78
    if id.positive?
×
UNCOV
79
      @current_id = id
×
UNCOV
80
    else
×
81
      new_self = nil
×
UNCOV
82
    end
×
UNCOV
83
    new_self
×
UNCOV
84
  end
×
UNCOV
85
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc