T
T
textballade2014-06-26 04:41:31
ruby
textballade, 2014-06-26 04:41:31

Why does a Rack application need to be an object and not a class?

All introductions to Rack emphasize that an application should be an object, not a class. Why? After all, this code will work:

class MyApp
    def self.call(env)
        [200,{},["text"]]
    end
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kryak, 2014-07-03
@sck_v

The application must respond to the "call" method.
So both MyApp.call and MyApp.new.call are valid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question