roda-action
A plugin for Roda to resolve actions from roda-container
Installation
gem 'roda-action', '0.0.1'
Usage
class MyApplication < Roda
plugin :action
end
class UsersController
attr_reader :repository
def initialize(repository = {})
@repository = repository
end
def index
repository.values
end
def show(user_id)
repository[user_id]
end
end
MyApplication.register(:users_controller) do
UsersController.new({
'1' => { name: 'Jack' },
'2' => { name: 'Gill' }
})
end
route do |r|
r.on 'users' do
r.is do
r.get(&MyApplication.action(:users_controller, :index))
end
r.is :id do |id|
r.get(&MyApplication.action(:users_controller, :show).bind_arguments(id))
end
end
end
Contributing
- Fork it ( https://github.com/AMHOL/roda-action )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request