Class: Rsec::Lazy

Inherits:
Unary
  • Object
show all
Defined in:
lib/rsec/parsers/misc.rb

Overview

sometimes a variable is not defined yet<br/> lazy is used to capture it later NOTE the value is captured the first time it is called

Instance Attribute Summary

Attributes inherited from Unary

#some

Attributes included from Parser

#name

Instance Method Summary collapse

Methods included from Parser

#&, #*, #<<, #>>, #^, #cached, #eof, #fail, #inspect, #join, #map, #maybe, #parse, #parse!, #star, #|

Instance Method Details

#_parse(ctx) ⇒ Object



157
158
159
160
161
162
163
164
165
# File 'lib/rsec/parsers/misc.rb', line 157

def _parse ctx
  @some ||= \
    begin
      some()[]
    rescue NameError => ex
      some().binding.eval ex.name.to_s
    end
  @some._parse ctx
end