Module: AwesomePrint::ProcExt

Defined in:
lib/awesome_print/proc_ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:startdoc:


9
10
11
12
# File 'lib/awesome_print/proc_ext.rb', line 9

def self.included(base)
  base.send :alias_method, :cast_without_proc, :cast
  base.send :alias_method, :cast, :cast_with_proc
end

Instance Method Details

#cast_with_proc(obj, type) ⇒ Object

Add Proc class to the dispatcher pipeline.


15
16
17
18
19
20
21
# File 'lib/awesome_print/proc_ext.rb', line 15

def cast_with_proc(obj, type)
  if (type == :proc || obj.is_a?(::Proc)) && obj.respond_to?(:to_source)
    :proc
  else
    cast_without_proc(obj, type)
  end
end