Sha256: f9148a650ab15fd712becc95f9789682350797785dccde6eb214108852edd66f
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module ConvenientService module Utils module Object class GetOwnMethod < Support::Command ## # @!attribute [r] object # @return [Object] Can be any type. # attr_reader :object ## # @!attribute [r] method_name # @return [Symbol, String] # attr_reader :method_name ## # @!attribute [r] private # @return [Boolean] # attr_reader :private ## # @param object [Object] Can be any type. # @param method_name [Symbol, String] # @param private [Boolean] # def initialize(object, method_name, private: false) @object = object @method_name = method_name @private = private end ## # @return [Class] # # @internal # NOTE: `own_method.bind(object).call` is logically the same as `own_method.bind_call(object)`. # - https://ruby-doc.org/core-2.7.1/UnboundMethod.html#method-i-bind_call # - https://blog.saeloun.com/2019/10/17/ruby-2-7-adds-unboundmethod-bind_call-method.html # def call own_method = Utils::Module.get_own_instance_method(object.class, method_name, private: private) return unless own_method own_method.bind(object) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
convenient_service-0.19.1 | lib/convenient_service/utils/object/get_own_method.rb |
convenient_service-0.19.0 | lib/convenient_service/utils/object/get_own_method.rb |