Class: Action
- Inherits:
-
HTTPServlet::AbstractServlet
- Object
- HTTPServlet::AbstractServlet
- Action
- Defined in:
- lib/bloggit/server.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#req ⇒ Object
readonly
Returns the value of attribute req.
-
#res ⇒ Object
readonly
Returns the value of attribute res.
Instance Method Summary collapse
- #do_GET(req, res) ⇒ Object
- #do_POST(req, res) ⇒ Object
- #get ⇒ Object
- #post ⇒ Object
- #render(template, binding = binding) ⇒ Object
- #site ⇒ Object
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/bloggit/server.rb', line 9 def content_type @content_type end |
#req ⇒ Object (readonly)
Returns the value of attribute req.
9 10 11 |
# File 'lib/bloggit/server.rb', line 9 def req @req end |
#res ⇒ Object (readonly)
Returns the value of attribute res.
9 10 11 |
# File 'lib/bloggit/server.rb', line 9 def res @res end |
Instance Method Details
#do_GET(req, res) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bloggit/server.rb', line 10 def do_GET(req, res) @req = req; @res = res @content_type = "text/html" @res.body = get @res['Content-Type'] = @content_type end |
#do_POST(req, res) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/bloggit/server.rb', line 16 def do_POST(req, res) @req = req; @res = res @content_type = "text/html" @res.body = post @res['Content-Type'] = @content_type end |
#get ⇒ Object
22 |
# File 'lib/bloggit/server.rb', line 22 def get; "GET not defined"; end |
#post ⇒ Object
23 |
# File 'lib/bloggit/server.rb', line 23 def post; "POST not defined"; end |
#render(template, binding = binding) ⇒ Object
24 25 26 27 28 |
# File 'lib/bloggit/server.rb', line 24 def render(template, binding=binding) source = IO.read(File.join(File.dirname(__FILE__), 'client', 'templates', "#{template}.rhtml")) puts "Rendering #{source}" ERB.new(source).result(binding) end |
#site ⇒ Object
29 30 31 |
# File 'lib/bloggit/server.rb', line 29 def site Bloggit::Server.active_site end |