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

pulibrary / allsearch_api / fbd93b84-a3a0-45de-804f-ccf926267a8a

01 Aug 2025 05:23PM UTC coverage: 99.514%. Remained the same
fbd93b84-a3a0-45de-804f-ccf926267a8a

push

circleci

web-flow
Merge pull request #388 from pulibrary/add-rake-to-gemfile

Explicitly include Rake in Gemfile

1024 of 1029 relevant lines covered (99.51%)

92.23 hits per line

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

100.0
/app/models/concerns/holdings.rb
1
# frozen_string_literal: true
2

3
# This module is responsible for dynamically
4
# creating methods that provide information
5
# about a catalog document's holdings
6
module Holdings
3✔
7
  private
3✔
8

9
  [:first, :second].each_with_index do |number, index|
3✔
10
    # Create the first_barcode and second_barcode methods
11
    define_method "#{number}_barcode" do
6✔
12
      send(:"#{number}_physical_holding")&.barcode
175✔
13
    end
14

15
    # Create the first_call_number and second_call_number methods
16
    define_method "#{number}_call_number" do
6✔
17
      send(:"#{number}_physical_holding")&.call_number
176✔
18
    end
19

20
    # Create the first_library and second_library methods
21
    define_method "#{number}_library" do
6✔
22
      send(:"#{number}_physical_holding")&.library
175✔
23
    end
24

25
    # Create the first_status and second_status methods
26
    define_method "#{number}_status" do
6✔
27
      send(:"#{number}_physical_holding")&.status
182✔
28
    end
29

30
    # Create the first_physical_holding and second_physical_holding methods
31
    define_method "#{number}_physical_holding" do
6✔
32
      # First, check to see if we've already stored this in an instance variable
33
      return instance_variable_get("@#{__method__}") if instance_variable_defined?("@#{__method__}")
708✔
34
      return unless holdings&.dig(index)
585✔
35

36
      instance_variable_set("@#{__method__}", PhysicalHolding.new(holding_id: holdings[index]&.first,
53✔
37
                                                                  holding_data: holdings[index]&.last,
38
                                                                  document_id: document[:id]))
39
    end
40
  end
41

42
  def holdings
3✔
43
    @holdings ||= begin
691✔
44
      holdings_string = document[:holdings_1display]
427✔
45
      if holdings_string.blank?
427✔
46
        nil
376✔
47
      else
48
        JSON.parse(holdings_string).to_a
51✔
49
      end
50
    end
51
  end
52
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

© 2025 Coveralls, Inc