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)


36
37
38
39
40
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 36

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.



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

def method_name
  @method_name
end

#modObject (readonly)

Returns the value of attribute mod.



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

def mod
  @mod
end

#privateObject (readonly)

Returns the value of attribute private.



28
29
30
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 28

def private
  @private
end

Instance Method Details

#callBoolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/convenient_service/utils/module/has_own_instance_method.rb', line 45

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