Sha256: df6023a63651e1a430a753ac3759629c89e9341ae0604b6a69838699c2e42a78

Contents?: true

Size: 915 Bytes

Versions: 8

Compression:

Stored size: 915 Bytes

Contents

class Remailer::Interpreter::StateProxy
  STATIC_CLASSES = [ String, Fixnum, NilClass, TrueClass, FalseClass, Float ].freeze
  
  def initialize(options, &block)
    @options = options
    
    instance_eval(&block) if (block_given?)
  end
  
  def parse(spec = nil, &block)
    @options[:parser] = Remailer::Interpreter.parser_for_spec(spec, &block)
  end
  
  def enter(&block)
    @options[:enter] ||= [ ]
    @options[:enter] << block
  end
  
  def interpret(response, &block)
    @options[:interpret] ||= [ ]
    @options[:interpret] << [ response, block ]
  end
  
  def default(&block)
    @options[:default] ||= [ ]
    @options[:default] << block
  end

  def leave(&block)
    @options[:leave] ||= [ ]
    @options[:leave] << block
  end
  
  def terminate(&block)
    @options[:terminate] ||= [ ]
    @options[:terminate] << block
  end

protected
  def rebind(options)
    @options = options
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
remailer-0.4.1 lib/remailer/interpreter/state_proxy.rb
remailer-0.4.0 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.8 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.6 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.4 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.2 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.1 lib/remailer/interpreter/state_proxy.rb
remailer-0.3.0 lib/remailer/interpreter/state_proxy.rb