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

Code-Vedas / mutils / 6060940963

02 Sep 2023 10:54PM CUT coverage: 100.0%. Remained the same
6060940963

push

github

niteshpurohit
chore: maintainance

1 of 1 new or added line in 1 file covered. (100.0%)

205 of 205 relevant lines covered (100.0%)

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

23
        def hashed_result(result_hash)
4✔
24
          fetch_block_attributes(self.class.attributes_to_serialize_blocks, result_hash)
352,312✔
25
          fetch_attributes(self.class.attributes_to_serialize, result_hash)
352,312✔
26
          hash_relationships(self.class.relationships, result_hash)
352,312✔
27

28
          result_hash.hash
352,312✔
29
        end
30

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

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

37
        def scope_is_collection?
4✔
38
          Lib::Helper.instance.collection? scope
352,480✔
39
        end
40

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

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