Module: Evil::Client::Names
Overview
Utility to remove unnecessary methods from instances to clear a namespace
Constant Summary collapse
- FORBIDDEN =
List of preserved methods. They also couldn’t be used as names of operations/scopes/options to avoid name conflicts.
i[ basic_auth class datetime hash inspect instance_exec instance_variable_get instance_variable_set key_auth logger logger object_id operation operations public_send schema scope scopes self send settings singleton_class tap to_s to_str token_auth load_dependency unloadable require_or_load require_dependency ].freeze
- FORMAT =
Matches whether a name can be used in operations/scopes/options
/^[a-z]([a-z\d_])*[a-z\d]$/.freeze
Instance Method Summary collapse
-
#clean(klass) ⇒ nil
Removes unused instance methods inherited from [Object] from given class.
Instance Method Details
#clean(klass) ⇒ nil
Removes unused instance methods inherited from [Object] from given class
15 16 17 18 |
# File 'lib/evil/client/names.rb', line 15 def clean(klass) (klass.instance_methods - BasicObject.instance_methods - FORBIDDEN) .each { |m| klass.send(:undef_method, m) if m[FORMAT] } && nil end |