Class: ConvenientService::Utils::Module::HasOwnInstanceMethod

Inherits:
Support::Command
  • Object
show all
Defined in:
lib/convenient_service/utils/module/has_own_instance_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(mod, method_name, private: false) ⇒ void

Parameters:

  • mod (Class, Module)
  • method_name (String, Symbol)
  • private (Boolean) (defaults to: false)


31
32
33
34
35
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 31

def initialize(mod, method_name, private: false)
  @mod = mod
  @method_name = method_name
  @private = private
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



17
18
19
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 17

def method_name
  @method_name
end

#modObject (readonly)

Returns the value of attribute mod.



11
12
13
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 11

def mod
  @mod
end

#privateObject (readonly)

Returns the value of attribute private.



23
24
25
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 23

def private
  @private
end

Instance Method Details

#callBoolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 40

def call
  method = method_name.to_sym

  return true if own_instance_methods.include?(method)

  if private
    return true if private_own_instance_methods.include?(method)
  end

  false
end