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

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

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

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

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

28
      def constantize(string)
2✔
29
        constantize_cache[string] = Object.const_get string unless constantize_cache[string]
96✔
30
        constantize_cache[string]
94✔
31
      end
32

33
      def collection?(object)
2✔
34
        object.respond_to?(:size) && !object.respond_to?(:each_pair)
176,398✔
35
      end
36

37
      private
2✔
38

39
      attr_accessor :inflector_object, :pluralize_cache, :underscore_cache, :constantize_cache
2✔
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