I have left my ruby books at home. I am looking at some code that has
stuff like

use Rack::Flash

and some other more complex statements similar to that. I am not sure
what "use" does and it is too common a word to google. Any links or
explanations would be appreciated ..

Thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Frederick Cheung at Apr 10, 2012 at 6:04 pm

    On Apr 10, 3:47 pm, Jedrin wrote:
    I have left my ruby books at home. I am looking at some code that has
    stuff like

    use Rack::Flash
    This (in a rack configuration file) tells rack to add the Rack::Flash
    middleware to the middleware stack. Hopefully that gives you something
    more explicit to google for

    Fred.
    and some other more complex statements similar to that. I am not sure
    what "use" does and it is too common a word to google. Any links or
    explanations would be appreciated ..

    Thanks
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Jedrin at Apr 25, 2012 at 1:56 pm
    Here is another one I don't quite understand. It seems like
    RequestLog is used for logging http requests,
    but I am not sure how it is getting set up. The second part
    where :logger is seen doesn't quite make sense either.

    Is the ruby use statement similar to the Perl use statement ? I saw
    some site trying to explain it in Perl a bit. I guess I need to try to
    locate my Programming in Ruby book tonight hopefully.

    if $config['mongo']

    begin

    require 'request_log'
    # customize the middleware with our own fields
    use RequestLog::Middleware,
    :logger => lambda { |data|
    RequestLog::Db.requests.insert(data.attributes.merge({:port =>
    data.env['SERVER_PORT'], :appname => "myapp"})) }


    end

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Jedrin at Apr 25, 2012 at 2:05 pm
    RequestLog is apparently from here:
    http://rubydoc.info/gems/request_log/0.1.2/frames

    It's starting to make a little more sense, as RequestLog::Middleware
    is a class I just realized, but I am not used
    to this type of approach ..

    module RequestLog
    class Middleware
    def initialize(app, options = {})
    @app = app
    @logger = options[:logger] || lambda { |
    data| ::RequestLog::Db.requests.insert(data.attributes) }
    @profiler = options[:profiler] || ::RequestLog::Profiler
    @timeout = options[:timeout] || 0.3
    @only_path = options[:only_path]
    end

    ..
    end
    ..
    end

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Frederick Cheung at Apr 25, 2012 at 2:27 pm

    On Apr 25, 8:56 am, Jedrin wrote:
    Here is another one I don't quite understand. It seems like
    RequestLog is used for logging http requests,
    but I am not sure how it is getting set up. The second part
    where :logger is seen doesn't quite make sense either.

    Is the ruby use statement similar to the Perl use statement ? I saw
    some site trying to explain it in Perl a bit. I guess I need to try to
    locate my Programming in Ruby book tonight hopefully.
    There is no ruby use statement. Rack defines a use method (probably
    using instance_eval, which is why it looks like you're calling a top
    level method) that takes a class as its argument, instantiates it and
    pushes it onto its list of middlewares

    Fred

    if $config['mongo']

    begin

    require 'request_log'
    # customize the middleware with our own fields
    use RequestLog::Middleware,
    :logger => lambda { |data|
    RequestLog::Db.requests.insert(data.attributes.merge({:port =>
    data.env['SERVER_PORT'], :appname => "myapp"})) }

    end
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 10, '12 at 2:47p
activeApr 25, '12 at 2:27p
posts5
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Jedrin: 3 posts Frederick Cheung: 2 posts

People

Translate

site design / logo © 2021 Grokbase