Module: Sinatra::AppModule::ClassMethods

Defined in:
lib/sinatra/support/appmodule.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



42
43
44
45
# File 'lib/sinatra/support/appmodule.rb', line 42

def method_missing(meth, *args, &blk)
  defer meth, *args, &blk
  nil
end

Instance Method Details

#defer(what, *a, &blk) ⇒ Object



47
48
49
# File 'lib/sinatra/support/appmodule.rb', line 47

def defer(what, *a, &blk)
  deferred << [what, a, blk]
end

#deferredObject



51
52
53
# File 'lib/sinatra/support/appmodule.rb', line 51

def deferred
  @deferred ||= Array.new
end

#included(app) ⇒ Object



38
39
40
# File 'lib/sinatra/support/appmodule.rb', line 38

def included(app)
  deferred.each { |(method, args, blk)| app.send method, *args, &blk }
end