Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasilakisfil/namespaced_mixin
namespace your mixins
https://github.com/vasilakisfil/namespaced_mixin
Last synced: 14 days ago
JSON representation
namespace your mixins
- Host: GitHub
- URL: https://github.com/vasilakisfil/namespaced_mixin
- Owner: vasilakisfil
- License: mit
- Created: 2014-10-19T18:24:21.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-10T10:48:05.000Z (almost 9 years ago)
- Last Synced: 2024-10-08T19:04:35.672Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# NamespacedMixin
Namespace your mixins. Proper Composition.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'namespaced_mixin'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install namespaced_mixin
## Usage
You can do such amazing things:```ruby
require 'namespaced_mixin'module TestModule
module NestedModule
def do_that
puts 'Do this'
end
end
endmodule TestModule1
def do_that
puts 'Doing that'
end
endmodule TestModule2
def do_that
puts 'Do something else'
end
endclass Example
include NamespacedMixinnamespace 'TestModule1', as: :simply
namespace 'TestModule2', as: :namespaced
namespace 'TestModule::NestedModule', as: :mixinsinclude AmazingModule
#rest of the code
def stupid_method
if simply.do_that == mixins.do_that
namespaced.do_that #do something else
end
end
end
```Usually the methods of the mixins that you want to use should not keep state (act like traits),
and support DI.## Contributing
1. Fork it ( https://github.com/[my-github-username]/namespaced_mixin/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