Class: Rack::Builder
- Inherits:
-
Object
- Object
- Rack::Builder
- Defined in:
- lib/rackjson/rack/builder.rb
Instance Method Summary collapse
-
#expose_resource(options) ⇒ Object
Setup resource collections without authentication.
-
#private_resource(options) ⇒ Object
Setup resource collections with no public access.
-
#public_resource(options) ⇒ Object
Setup resource collections with public read access but write access only given to the owner of the document, determened from the session var passed as filter.
Instance Method Details
#expose_resource(options) ⇒ Object
Setup resource collections without authentication.
Example
expose_resource :collections => [:notes, :projects], :db => @mongo_db
8 9 10 11 12 |
# File 'lib/rackjson/rack/builder.rb', line 8 def expose_resource @ins << lambda do |app| Rack::JSON::Resource.new app, end end |
#private_resource(options) ⇒ Object
Setup resource collections with no public access. Read and write access only given to the owner of the document, determened from the session vars passed as filters.
Example
private_resource :collections => [:notes, :projects], :db => @mongo_db, :filters => [:user_id]
36 37 38 39 40 41 42 |
# File 'lib/rackjson/rack/builder.rb', line 36 def private_resource @ins << lambda do |app| Rack::JSON::Filter.new( Rack::JSON::Resource.new(app, ), .merge(:methods => [:get, :post, :put, :delete])) end end |
#public_resource(options) ⇒ Object
Setup resource collections with public read access but write access only given to the owner of the document, determened from the session var passed as filter.
Example
public_resource :collections => [:notes, :projects], :db => @mongo_db, :filters => [:user_id]
21 22 23 24 25 26 27 |
# File 'lib/rackjson/rack/builder.rb', line 21 def public_resource @ins << lambda do |app| Rack::JSON::Filter.new( Rack::JSON::Resource.new(app, ), .merge(:methods => [:post, :put, :delete])) end end |