You can clone with
Is there any reason why the arguments order is switched for the format specific methods?
Rabl::Renderer.new('posts/show', @post, :view_path => 'app/views', :format => 'hash').render
Yeah, I didn't like that either when I was last looking at the code. The problem was an internal method had an optional argument at the end so it was needed.
For .jsonFor .new
See how .new's object is optionally set to nil. But the (object, source) argument order of .json are both required.
Why that order? I don't know, I didn't accept the PR but now we're stuck with it.
If @nesquena has any ideas as to the details, I'd be enlightened.
Too bad we can't create another initializer. The easiest hack/fix would be to replace the current initializer with just *args and interpret the number of arguments being used. If args.size > 1, then it's "old school". Otherwise a single hash is the "new way". Then we can just pick any order you want. Like I said, its a complete hack to allow better CoP but at the cost of a few ugly lines in the initializer.
I'll let @nesquena pick this one apart.
Since there's no immediate solution proposed, I'll close it. We can open a new issue with code attached if we have a solution.
Yeah I claim full responsibility for not catching that when I accepted the pull request. The reordering of parameters in that way does seem pretty inconsistent. I think we are stuck with it for the time being but we can likely correct it in time for an API breaking 1.0 release #216
Oh and thanks for digging into that david, I suspect that optional param there is probably what encouraged Ivan to swap the parameters. But I think we could keep the ordering consistent and achieve that in a different way.
Hi @nesquena, awesome, looking forward to 1.0, do you have any goal date for releasing it?
I was actually planning to start on it more seriously in the next couple months. I'd love to have something for people to play with (preview release) by January.