https://github.com/bagilevi/application_module
Ruby gem that helps breaking down a Rails app into modules
https://github.com/bagilevi/application_module
Last synced: 3 months ago
JSON representation
Ruby gem that helps breaking down a Rails app into modules
- Host: GitHub
- URL: https://github.com/bagilevi/application_module
- Owner: bagilevi
- License: mit
- Created: 2013-08-02T19:37:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-08-04T16:29:11.000Z (almost 11 years ago)
- Last Synced: 2025-01-13T04:41:49.180Z (4 months ago)
- Language: Ruby
- Size: 171 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ApplicationModule
This gem is meant to help with breaking down large Rails apps into modules.
[](https://travis-ci.org/bagilevi/application_module) [](https://codeclimate.com/github/bagilevi/application_module)
## Installation
Add this line to your application's Gemfile:
gem 'application_module'
And then execute:
$ bundle
Or install it yourself as:
$ gem install application_module
## Usage
Create a directory for your modules. A `modules` directory in the app
root works well for me.In `config/application.rb`:
config.autoload_paths += %W(#{config.root}/modules)
For each module, create a subdirectory and a ruby file:
modules/animals.rb
modules/animals/`animals.rb`
module Animals
extend ApplicationModule
endNow you can create files like `modules/animals/tiger.rb` and
`Animals::Tiger` will be autoloaded from here.You can create the usual `controllers/`, `models/`, `views/`
directories under `modules/animals/`, the classes in these need to be
namespaced under `Animals::`, but not
`Animals::Controllers::`.By default if you want a subdirectory `services/`, then it will be
assumed that classes under it will be namespaced as
`Animals::Services::`. If you want it to behave like the
`controllers/` and other directories, you can do this:module Animals
extend ApplicationModule
autoload_without_namespacing 'services'
end## Contributing
1. Fork it
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 new Pull Request