Class: Textpow::SyntaxProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ver/vendor/textpow.rb

Instance Method Summary collapse

Constructor Details

#initialize(proxy, syntax) ⇒ SyntaxProxy

Returns a new instance of SyntaxProxy.



59
60
61
62
# File 'lib/ver/vendor/textpow.rb', line 59

def initialize proxy, syntax
  @proxy, @syntax = proxy, syntax
  @proxy_value = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ver/vendor/textpow.rb', line 64

def method_missing(method, *args, &block)
  if @proxy
    @proxy_value ||= proxy

    if @proxy_value
      @proxy_value.send(method, *args, &block)
    else
      # warn "Failed proxying #{@proxy}.#{method}(#{args.join(', ')})"
    end
  else
    super
  end
end

Instance Method Details

#proxyObject



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ver/vendor/textpow.rb', line 78

def proxy
  case @proxy
  when /^#(.+)/
    return unless @syntax.repository
    @syntax.repository[$1.to_sym]
  when "$self", "$base"
    @syntax
  else
    @syntax.syntaxes[@proxy]
  end
end