Module: MetaInstance::ModuleExtensions
- Extended by:
- ActiveSupport::Concern
- Includes:
- FreezeMethod
- Included in:
- Proxy
- Defined in:
- lib/meta_instance/module_extensions.rb
Overview
ModuleExtensions provides some additional methods for Module and Class objects.
TODO: Are there any other module/class methods that need to be provided?
Constant Summary
Constants included from FreezeMethod
Instance Method Summary collapse
-
#method_definition(name) ⇒ Object
(also: #definition)
Get a first-class method definition object.
-
#method_definitions(*selection) ⇒ Object
(also: #definitions)
List of method definitions in a module or class.
Instance Method Details
#method_definition(name) ⇒ Object Also known as: definition
Get a first-class method definition object.
Returns an unbound method object. [UnboundMethod]
56 57 58 |
# File 'lib/meta_instance/module_extensions.rb', line 56 def method_definition(name) bind_call(:instance_method, name) end |
#method_definitions(*selection) ⇒ Object Also known as: definitions
List of method definitions in a module or class.
selection - Any of ‘:public`, `:protected` or `:private` which
is used to select specific subsets of methods.
Returns [Array<Symbol>]
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/meta_instance/module_extensions.rb', line 29 def method_definitions(*selection) list = [] if selection.empty? list.concat bind_call(:instance_methods) end selection.each do |s| case s when :public, :all list.concat bind_call(:public_instance_methods) when :protected, :all list.concat bind_call(:protected_instance_methods) when :private, :all list.concat bind_call(:private_instance_methods) end end return list end |