https://github.com/namusyaka/sinatra-bind
Sinatra Extension for binding instance method to routes
https://github.com/namusyaka/sinatra-bind
Last synced: about 1 month ago
JSON representation
Sinatra Extension for binding instance method to routes
- Host: GitHub
- URL: https://github.com/namusyaka/sinatra-bind
- Owner: namusyaka
- License: mit
- Created: 2014-12-05T05:58:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-05T06:01:04.000Z (over 10 years ago)
- Last Synced: 2025-04-09T02:29:13.871Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 117 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Sinatra::Bind
Binds instance method to routes.
## Installation
Add this line to your application's Gemfile:
gem 'sinatra-bind'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sinatra-bind
## Usage
You can define a route without block smoothly.
```ruby
class App < Sinatra::Base
register Sinatra::Binddef index
"hello world"
endon "/", to: :index
end
```If specified the :type option, it will be used as request method.
```ruby
class App < Sinatra::Base
register Sinatra::Binddef index
"hello world"
endon "/", to: :index, type: :post
end
```If passed `:before` or `:after` inn the `:type` option, it will be added as the filters.
```ruby
class App < Sinatra::Base
register Sinatra::Binddef before_index
@foo = "bob"
enddef index
"hello #{@foo}"
endon "/", to: :before_index, type: :before
on "/", to: :index
end
```## Contributing
1. Fork it ( https://github.com/namusyaka/sinatra-bind/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request