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

Code-Vedas / mutils / 9707403017

28 Jun 2024 04:22AM CUT coverage: 100.0%. Remained the same
9707403017

push

github

niteshpurohit
fix: rubocop >= 1.63.3

205 of 205 relevant lines covered (100.0%)

28368.16 hits per line

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

100.0
/lib/mutils/serialization/results/main.rb
1
# frozen_string_literal: true
2

3
# Module Mutils
4
module Mutils
2✔
5
  module Serialization
2✔
6
    # Module Results
7
    module Results
2✔
8
      # Module Attributes
9
      module Main
2✔
10
        def generate_hash
2✔
11
          if scope
176,212✔
12
            if scope_is_collection?
176,208✔
13
              options[:child] = true
52✔
14
              scope.map { |inner_scope| self.class.new(inner_scope, options).generate_hash }
176,126✔
15
            else
16
              hashed_result(Lib::ResultHash.new)
176,156✔
17
            end
18
          else
19
            {}
4✔
20
          end
21
        end
22

23
        def hashed_result(result_hash)
2✔
24
          fetch_block_attributes(self.class.attributes_to_serialize_blocks, result_hash)
176,156✔
25
          fetch_attributes(self.class.attributes_to_serialize, result_hash)
176,156✔
26
          hash_relationships(self.class.relationships, result_hash)
176,156✔
27

28
          result_hash.hash
176,156✔
29
        end
30

31
        def check_if_included(s_options, key)
2✔
32
          return s_options[:if].call(scope, options[:params] || {}) unless s_options[:if].nil? || scope_is_collection?
704,540✔
33

34
          s_options[:always_include] || options[:includes]&.include?(key)
704,512✔
35
        end
36

37
        def scope_is_collection?
2✔
38
          Lib::Helper.instance.collection? scope
176,240✔
39
        end
40

41
        def class_name
2✔
42
          if scope_is_collection?
4✔
43
            Lib::Helper.instance.pluralize(format_class_name(scope[0]))
2✔
44
          else
45
            format_class_name(scope)
2✔
46
          end
47
        end
48

49
        def format_class_name(object)
2✔
50
          if self.class.serializer_name&.length&.positive?
4✔
51
            self.class.serializer_name
2✔
52
          else
53
            object.class.to_s.downcase
2✔
54
          end
55
        end
56
      end
57
    end
58
  end
59
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