Class: Herbert::Resource
- Inherits:
-
Object
- Object
- Herbert::Resource
- Defined in:
- lib/herbert/Resource.rb
Overview
When extended, it virtually “merges” the overriding class into the app.
class Messages
get '/'
end
end
will enable your app to respond to
GET /messages/
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Translates Sinatra DSL calls.
-
.new ⇒ Object
Instantizing this class is forbidden.
Class Method Details
.inherited(subclass) ⇒ Object
Translates Sinatra DSL calls
18 19 20 21 22 23 24 |
# File 'lib/herbert/Resource.rb', line 18 def self.inherited(subclass) %w{get post put delete}.each do |verb| subclass.define_singleton_method verb.to_sym do |route, &block| app.send verb.to_sym, "/#{subclass.to_s.downcase}#{route}", &block end end end |
.new ⇒ Object
Instantizing this class is forbidden
13 14 15 |
# File 'lib/herbert/Resource.rb', line 13 def self.new raise StandardError.new('You are not allowed to instantize this class directly') end |