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

Code-Vedas / mutils / 4249393637

pending completion
4249393637

push

github

GitHub
build(deps): bump rubocop from 1.45.1 to 1.46.0 (#239)

205 of 205 relevant lines covered (100.0%)

14184.08 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
1✔
5
  module Serialization
1✔
6
    # Module Results
7
    module Results
1✔
8
      # Module Attributes
9
      module Main
1✔
10
        def generate_hash
1✔
11
          if scope
88,106✔
12
            if scope_is_collection?
88,104✔
13
              options[:child] = true
26✔
14
              scope.map { |inner_scope| self.class.new(inner_scope, options).generate_hash }
88,063✔
15
            else
16
              hashed_result(Lib::ResultHash.new)
88,078✔
17
            end
18
          else
19
            {}
2✔
20
          end
21
        end
22

23
        def hashed_result(result_hash)
1✔
24
          fetch_block_attributes(self.class.attributes_to_serialize_blocks, result_hash)
88,078✔
25
          fetch_attributes(self.class.attributes_to_serialize, result_hash)
88,078✔
26
          hash_relationships(self.class.relationships, result_hash)
88,078✔
27

28
          result_hash.hash
88,078✔
29
        end
30

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

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

37
        def scope_is_collection?
1✔
38
          Lib::Helper.instance.collection? scope
88,120✔
39
        end
40

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

49
        def format_class_name(object)
1✔
50
          if self.class.serializer_name&.length&.positive?
2✔
51
            self.class.serializer_name
1✔
52
          else
53
            object.class.to_s.downcase
1✔
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