Adds support for multiple column (backwards compatible)#26
Adds support for multiple column (backwards compatible)#26pyromaniac merged 16 commits intomongoid:masterfrom
Conversation
* Cleanup main orderable.rb * Eliminated the configurable module * Generate dynamic #move_to, #list, #insert based on column * Minor fixes, etc.
…n, fix minor issue in listable generator
|
Such an awesome work! Could you please just fix 1.8.7 support and I'll merge it. I just don't want to reject 1.8.7 support because it costs almost nothing to bring it to gem. Just replace all the new-style hashes with the old ones (https://travis-ci.org/pyromaniac/mongoid_orderable/jobs/27887206) please. Thanks in advance. |
|
Hi @pyromaniac, thanks for the appreciation :) Ruby 1.8.7 does not provide support for default arguments in #define_method, so i'll need to convert it to #class_eval for such methods. Also, in ruby 1.8, to make an argument have a default value, the next argument(s) must also have a default value. so basically method such as: will also need to be changed. I am agnostic to above changes, but not sure whether should we continue with the ruby 1.8 support ? |
|
We can drop it if it will be impossible to implement. So do something with it ;) |
|
Cool... I'll work on it over the next couple of days and see how it goes. |
|
Wonderful, thanks! |
|
@pyromaniac let's drop Ruby 1.8 support. Ruby 1.8.x is 1 year past end-of-life, and it is not supported by Mongoid 3. I do not know of many other gems still supporting it. |
|
Let's do it! |
…for define_method, etc.
|
@pyromaniac - i have fixed the build for ruby 1.8 also, it should be good to merge now. |
Adds support for multiple column (backwards compatible)
|
So awesome, thanks! |
|
Thanks for the merge @pyromaniac I think it would also be good to bump and release a new version of mongoid_orderable with the above changes, so i can use the released version directly. |
|
One more PR to merge |
|
@Bharat311 - Hi, thank you for an awesome PR. class Foo
include Mongoid::Document
include Mongoid::Orderable
orderable column: :position
end
class Bar < Foo
endBefore I pulled the latest revision, I examined if the Are there any way to define the configuration in the abstract class and inherit it without defining again in the inherited classes? Thanks! |
|
I thinks it might be fixed by using |
|
@pyromaniac - Thanks! I sent a PR. https://github.com/pyromaniac/mongoid_orderable/pull/28 |
This PR allows defining multiple orderable columns ( fixes #23 ) like:
The code sets up a class_attribute orderable_configurations which is a hash of all the configurations and then generates helpers like:
This code change is backwards compatible, so existing implementations will also work.
In these case, the default configuration (default: true) or the first configuration is used.
Tested it for Mongoid 2, 3, 4 on a Rails 3 app - https://github.com/bharat311/mongoid_orderable_demo