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

ruby-smart / support / #8

03 Jul 2024 08:24PM CUT coverage: 99.083%. Remained the same
#8

push

gonzo4711
## [1.5.0] - 2024-07-03
* **[add]** `RubySmart::Support::ThreadInfo.debugger?`-detection to determinate if a **Debugger** gem is active
* **[fix]** `String#to_boolean`-method to detect false-values (which makes all other values become true - similar to `::ActiveRecord::Type::Boolean`)

3 of 3 new or added lines in 2 files covered. (100.0%)

216 of 218 relevant lines covered (99.08%)

71.17 hits per line

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

100.0
/lib/ruby_smart/support/core_ext/ruby/object.rb
1
# frozen_string_literal: true
2

3
unless Object.method_defined? "numeric?"
1✔
4
  class Object
1✔
5
    # returns true if this object is a numeric or a kind of numeric
6
    # @return [Boolean] numeric
7
    def numeric?
1✔
8
      return true if self.is_a?(Numeric)
6✔
9
      return true if self.to_s =~ /\A\d+\Z/
4✔
10
      return true if Float(self) rescue false
3✔
11

12
      false
2✔
13
    end
14
  end
15
end
16

17
unless Object.method_defined? "boolean?"
1✔
18
  class Object
1✔
19
    # return true if object is a boolean class (TrueClass or FalseClass)
20
    # @return [Boolean] boolean
21
    def boolean?
1✔
22
      self.is_a?(TrueClass) || self.is_a?(FalseClass)
5✔
23
    end
24
  end
25
end
26

27
unless Object.method_defined? "missing_method?"
1✔
28
  class Object
1✔
29
    # returns true if method is missing.
30
    # the second optional parameter <tt>check_ancestors</tt> prevents to check it's ancestors by providing a *false* value
31
    # @param [Symbol] name - the method's name to check
32
    # @param [Boolean] check_ancestors - check class ancestors (default: true)
33
    # @return [Boolean] missing_method
34
    def missing_method?(name, check_ancestors = true)
1✔
35
      !self.instance_methods(check_ancestors).include?(name)
11✔
36
    end
37
  end
38
end
39

40
unless Object.method_defined? "alias_missing_method"
1✔
41
  class Object
1✔
42
    # creates an alias for provided method if it's missing.
43
    # the third optional parameter <tt>check_ancestors</tt> prevents to check it's ancestors by providing a *false* value
44
    # @param [Symbol] new - new method name
45
    # @param [Symbol] old - old method name
46
    # @param [Boolean] check_ancestors - check class ancestors (default: true)
47
    def alias_missing_method(new, old, check_ancestors = true)
1✔
48
      alias_method(new, old) if missing_method?(new, check_ancestors)
3✔
49
    end
50
  end
51
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