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

Code-Vedas / mutils / 4310584822

pending completion
4310584822

push

github

GitHub
build(deps): bump rubocop from 1.46.0 to 1.47.0 (#240)

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/lib/helper.rb
1
# frozen_string_literal: true
2

3
require 'singleton'
1✔
4
# module Mutils
5
module Mutils
1✔
6
  module Lib
1✔
7
    # Helper: caching expensive repetitive operations
8
    class Helper
1✔
9
      include Singleton
1✔
10

11
      def initialize
1✔
12
        self.inflector_object = Dry::Inflector.new
1✔
13
        self.pluralize_cache = {}
1✔
14
        self.underscore_cache = {}
1✔
15
        self.constantize_cache = {}
1✔
16
      end
17

18
      def underscore(string)
1✔
19
        underscore_cache[string] = inflector_object.underscore string unless underscore_cache[string]
5✔
20
        underscore_cache[string]
5✔
21
      end
22

23
      def pluralize(string)
1✔
24
        pluralize_cache[string] = inflector_object.pluralize string unless pluralize_cache[string]
29✔
25
        pluralize_cache[string]
29✔
26
      end
27

28
      def constantize(string)
1✔
29
        constantize_cache[string] = Object.const_get string unless constantize_cache[string]
48✔
30
        constantize_cache[string]
47✔
31
      end
32

33
      def collection?(object)
1✔
34
        object.respond_to?(:size) && !object.respond_to?(:each_pair)
88,199✔
35
      end
36

37
      private
1✔
38

39
      attr_accessor :inflector_object, :pluralize_cache, :underscore_cache, :constantize_cache
1✔
40
    end
41
  end
42
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