Parent

Class Index [+]

Quicksearch

TryMe

This is the sample Synfeld::App described in the README.rdoc

Public Instance Methods

add_routes() click to toggle source

(Not documented)

# File example/try_me.rb, line 7
  def add_routes
    add_route "/yap/:yap_variable", :action => "yap" 
    add_route "/html_test", :action => "html_test" 
    add_route "/haml_test", :action => "haml_test" 
    add_route "/erb_test",  :action => "erb_test" 
    add_route '/alphabet.:format', :action => "alphabet" 
    add_route "/my/special/route", :action => "my_special_route", 
                                   :extra_parm1 => 'really', 
                                   :extra_parm2 => 'truly' 
    add_route '/', :action => "home" 
  end
alphabet() click to toggle source

(Not documented)

# File example/try_me.rb, line 40
  def alphabet
    alphabet = ('a'..'z').collect{|ch|ch} 
    case params[:format]
    when 'html'
      return "<html><body>#{alphabet.join("<br/>")}</body></html>"
    when 'json'
      hash = {:desc => 'here is the alphabet', :alphabet => alphabet}
      render_json hash.to_json
    else
      raise "Format not recognized: #{params[:format]}"
    end
  end
erb_test() click to toggle source

(Not documented)

# File example/try_me.rb, line 36
  def erb_test 
    render_erb('erb_files/erb_test.erb', :ran100 => Kernel.rand(100) + 1, :time => Time.now)
  end
haml_test() click to toggle source

(Not documented)

# File example/try_me.rb, line 32
  def haml_test 
    render_haml('haml_files/haml_test.haml', :ran100 => Kernel.rand(100) + 1, :time => Time.now)
  end
home() click to toggle source

files are looked up relative to the root directory specified in initialize

# File example/try_me.rb, line 20
  def home
    render_haml('haml_files/home.haml')
  end
html_test() click to toggle source

(Not documented)

# File example/try_me.rb, line 28
  def html_test 
    render_html('html_files/html_test.html')
  end
my_special_route() click to toggle source

(Not documented)

# File example/try_me.rb, line 53
  def my_special_route
    self.response[:status_code] = 200
    self.response[:headers]['Content-Type'] = 'text/html'
    self.response[:body] = "<html>\n<body>I'm <i>special</i>,\n\#{self.params[:extra_parm1]} and \#{self.params[:extra_parm2]}</body>\n</html>\n"
  end
yap() click to toggle source

(Not documented)

# File example/try_me.rb, line 24
  def yap
    "yap, #{self.params[:yap_variable]}"
  end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.