boxer
boxer copied to clipboard
Boxer.ship_all Method for Collections
Boxer.ship_all(:course, Course.all, :root_key => 'my_courses')
What is the last parameter supposed to mean, some kind of condition?
Or will it also be of the kind
:view => 'view_name
Good question. The intention is for the last argument to be a hash just like with ship
, but it'll recognize two special keys instead of one: root_key
in addition to view
.
The value of root_key
would be used as the name of the key in the resulting hash. under which the array of shipped objects would be placed, e.g.
{
"my_courses": […]
}
The rest of the pairs in that last argument hash would be sent along to each box, just as with ship
.
This looks like a good solution. Would be nice to include some additional values at the top level, such as for paging (per_page, page, results (a count)).
Any suggestions on how to implement this until Boxer ship_all is included?
I wrote my own simple version of ship-all
class Boxer
def self.ship_all(type, objects, *args)
objects.map { |o| Boxer.ship(type, o, *args) }
end
end