Module: Rewrite::ByExample::ClassMethods

Defined in:
lib/rewrite/by_example.rb

Constant Summary collapse

DOGFOODER =

Sigh, I know that ‘clever’ variable names are not helpful, but I need to remind myself why I am doing this: Using a ByExample to extract what we want from a sexp is eating my own dog food.

ObjectToMatcher.from_object(
  s(:proc,
    nil,
    Bind.new(:body, AnyEntity.new)
  )
)

Instance Method Summary collapse

Instance Method Details

#from(&proc) ⇒ Object



22
23
24
25
# File 'lib/rewrite/by_example.rb', line 22

def from(&proc)
  body = DOGFOODER.unfold(proc.to_sexp) or raise "Don't know how to handle #{proc.to_ruby}"
  SexpEntity.from(body)
end