Class: ConvenientService::Utils::Method::Remove

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/method/remove.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(method, klass, public: true, protected: true, private: false) ⇒ void

Parameters:

  • method (Symbol, String)
  • klass (Class)
  • public (Boolean) (defaults to: true)
  • protected (Boolean) (defaults to: true)
  • private (Boolean) (defaults to: false)


54
55
56
57
58
59
60
# File 'lib/convenient_service/utils/method/remove.rb', line 54

def initialize(method, klass, public: true, protected: true, private: false)
  @method = method.to_s
  @klass = klass
  @public = public
  @protected = protected
  @private = private
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



22
23
24
# File 'lib/convenient_service/utils/method/remove.rb', line 22

def klass
  @klass
end

#methodObject (readonly)

Returns the value of attribute method.



16
17
18
# File 'lib/convenient_service/utils/method/remove.rb', line 16

def method
  @method
end

#privateObject (readonly)

Returns the value of attribute private.



40
41
42
# File 'lib/convenient_service/utils/method/remove.rb', line 40

def private
  @private
end

#protectedObject (readonly)

Returns the value of attribute protected.



34
35
36
# File 'lib/convenient_service/utils/method/remove.rb', line 34

def protected
  @protected
end

#publicObject (readonly)

Returns the value of attribute public.



28
29
30
# File 'lib/convenient_service/utils/method/remove.rb', line 28

def public
  @public
end

Instance Method Details

#callClass

Returns:



69
70
71
72
73
# File 'lib/convenient_service/utils/method/remove.rb', line 69

def call
  return unless Utils::Method.defined?(method, klass, public: public, protected: protected, private: private)

  klass.remove_method method
end