Module: FindRefined

Defined in:
lib/find_refined.rb,
lib/find_refined/finder.rb,
lib/find_refined/version.rb

Constant Summary collapse

VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.find(mod, type) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/find_refined/finder.rb', line 3

def find mod, type
  refined_methods = []
  mod.module_eval do
    refine type do
      refined_methods = instance_methods(false)
    end
  end
  refined_methods
end

.find_ancestors(mod, type) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/find_refined/finder.rb', line 14

def find_ancestors mod, type
  refined_methods = {}
  val = type.new
  val.class.ancestors.each do |ancestor|
    refined_methods[ancestor] = find(mod, ancestor)
  end
  refined_methods
end

.find_basic(mod) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/find_refined/finder.rb', line 24

def find_basic mod
  refined_methods = {}
  [NilClass, Symbol, Numeric, String, Array, Hash, Range].each do |type|
    refined_methods[type] = find(mod, type)
  end
  refined_methods
end