Sha256: 80c54c8ea332ded85be40fb91b313d9250d164075508154c8979d8a10bae9618

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Utils
    module Module
      class InstanceMethodDefined < Support::Command
        ##
        # @!attribute [r] mod
        #   @return [Class, Module]
        #
        attr_reader :mod

        ##
        # @!attribute [r] method_name
        #   @return [String, Symbol]
        #
        attr_reader :method_name

        ##
        # @!attribute [r] public
        #   @return [Boolean]
        #
        attr_reader :public

        ##
        # @!attribute [r] protected
        #   @return [Boolean]
        #
        attr_reader :protected

        ##
        # @!attribute [r] private
        #   @return [Boolean]
        #
        attr_reader :private

        ##
        # @param mod [Class, Module]
        # @param method_name [String, Symbol]
        # @param public [Boolean]
        # @param protected [Boolean]
        # @param private [Boolean]
        # @return [void]
        #
        # @internal
        #   NOTE: `protected` is set to `true` by default to keep the same semantics as `Module#method_defined?`.
        #   - https://ruby-doc.org/core-3.1.0/Module.html#method-i-method_defined-3F
        #
        def initialize(mod, method_name, public: true, protected: true, private: false)
          @mod = mod
          @method_name = method_name
          @public = public
          @protected = protected
          @private = private
        end

        ##
        # @return [Boolean]
        #
        def call
          Utils::Method.defined?(method_name, mod, public: public, protected: protected, private: private)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.19.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.18.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.17.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.16.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.15.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.14.0 lib/convenient_service/utils/module/instance_method_defined.rb
convenient_service-0.13.0 lib/convenient_service/utils/module/instance_method_defined.rb