Sha256: afea006e89e93495846f892987082ffceb2a3e731b9c1b0cad1311815ede7618
Contents?: true
Size: 1.13 KB
Versions: 9
Compression:
Stored size: 1.13 KB
Contents
class Cmds class ERBContext < BasicObject attr_reader :args def initialize args, kwds, tokenize_options_opts: {} @args = args @kwds = kwds @arg_index = 0 @tokenize_options_opts = tokenize_options_opts end def method_missing sym, *args, &block if args.empty? && block.nil? if sym.to_s[-1] == '?' key = sym.to_s[0...-1].to_sym # allow `false` to be omitted as well as missing and `nil` # by returning `nil` if the value is "false-y" @kwds[key] if @kwds[key] else if @kwds.key? sym @kwds[sym] elsif @kwds.key? sym.to_s @kwds[sym.to_s] else ::Kernel.raise ::KeyError.new ::NRSER.squish <<-END couldn't find keys #{ sym.inspect } or #{ sym.to_s.inspect } in keywords #{ @kwds.inspect } END end end else super sym, *args, &block end end def get_binding ::Kernel.send :binding end def arg @args.fetch(@arg_index).tap {@arg_index += 1} end end # end ERBContext end # class Cmds
Version data entries
9 entries across 9 versions & 1 rubygems