Module Aquarium::Utils::MethodUtils
In: lib/aquarium/utils/method_utils.rb

Methods

Public Class methods

Which type in a hierarchy actually defines a method?

[Source]

    # File lib/aquarium/utils/method_utils.rb, line 49
49:       def self.definer type_or_instance, method_sym, class_or_instance_only = nil
50:         return nil if type_or_instance.nil? or method_sym.nil? 
51:         return nil unless has_method(type_or_instance, method_sym, class_or_instance_only)
52:         ancestors  = ancestors_for type_or_instance
53:         determine_definer ancestors, type_or_instance, method_sym, class_or_instance_only
54:       end

[Source]

    # File lib/aquarium/utils/method_utils.rb, line 34
34:       def self.find_method type_or_instance, method_sym, class_or_instance_only = nil, include_ancestors = true
35:         meta_method_suffixes = determine_meta_method_suffixes type_or_instance, class_or_instance_only
36:         meta_method_suffixes.each do |suffix|
37:           %w[public protected private].each do |protection|
38:             meta_method = "#{protection}_#{suffix}"
39:             found_methods = type_or_instance.send(meta_method, include_ancestors)
40:             if found_methods.include?(method_sym.to_s)
41:               return yield(type_or_instance, method_sym, protection.intern)
42:             end
43:           end
44:         end
45:         nil
46:       end

[Source]

    # File lib/aquarium/utils/method_utils.rb, line 27
27:       def self.has_method type_or_instance, method_sym, class_or_instance_only = nil, include_ancestors = true
28:         found = find_method(type_or_instance, method_sym, class_or_instance_only, include_ancestors) do |t_or_o, msym, protection| 
29:           true
30:         end 
31:         found ? true : false   # found could be nil; return false, if so
32:       end

[Source]

    # File lib/aquarium/utils/method_utils.rb, line 8
 8:       def self.method_args_to_hash *args
 9:         return {} if args.empty? || (args.size == 1 && args[0].nil?)
10:         hash = (args[-1] and args[-1].kind_of? Hash) ? args.pop : {}
11:         args.each do |arg|
12:           if block_given?
13:             hash[arg] = yield arg
14:           else 
15:             hash[arg] = nil
16:           end
17:         end
18:         hash
19:       end

[Source]

    # File lib/aquarium/utils/method_utils.rb, line 21
21:       def self.visibility type_or_instance, method_sym, class_or_instance_only = nil, include_ancestors = true
22:         find_method(type_or_instance, method_sym, class_or_instance_only, include_ancestors) do |t_or_o, msym, protection| 
23:           protection
24:         end
25:       end

[Validate]