lib/hanami/utils/basic_object.rb in hanami-utils-1.3.1 vs lib/hanami/utils/basic_object.rb in hanami-utils-1.3.2

- old
+ new

@@ -27,9 +27,54 @@ "#<#{self.class}:#{'0x0000%x' % (__id__ << 1)}#{__inspect}>" end # rubocop:enable Style/FormatStringToken # rubocop:enable Style/FormatString + # @!macro [attach] instance_of?(class) + # + # Determine if self is an instance of given class or module + # + # @param class [Class,Module] the class of module to verify + # + # @return [TrueClass,FalseClass] the result of the check + # + # @raise [TypeError] if the given argument is not of the expected types + # + # @since 1.3.2 + # + # @see http://ruby-doc.org/core/Object.html#method-i-instance_of-3F + define_method :instance_of?, ::Object.instance_method(:instance_of?) + + # @!macro [attach] is_a?(class) + # + # Determine if self is of the type of the object class or module + # + # @param class [Class,Module] the class of module to verify + # + # @return [TrueClass,FalseClass] the result of the check + # + # @raise [TypeError] if the given argument is not of the expected types + # + # @since 1.3.2 + # + # @see http://ruby-doc.org/core/Object.html#method-i-is_a-3F + define_method :is_a?, ::Object.instance_method(:is_a?) + + # @!macro [attach] kind_of?(class) + # + # Determine if self is of the kind of the object class or module + # + # @param class [Class,Module] the class of module to verify + # + # @return [TrueClass,FalseClass] the result of the check + # + # @raise [TypeError] if the given argument is not of the expected types + # + # @since 1.3.2 + # + # @see http://ruby-doc.org/core/Object.html#method-i-kind_of-3F + define_method :kind_of?, ::Object.instance_method(:kind_of?) + # Alias for __id__ # # @return [Fixnum] the object id # # @since 0.9.0