boxer icon indicating copy to clipboard operation
boxer copied to clipboard

Boxer.ship_all Method for Collections

Open h3h opened this issue 12 years ago • 4 comments

Boxer.ship_all(:course, Course.all, :root_key => 'my_courses')

h3h avatar Nov 17 '11 16:11 h3h

What is the last parameter supposed to mean, some kind of condition? Or will it also be of the kind :view => 'view_name

i-arindam avatar Dec 04 '11 14:12 i-arindam

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.

h3h avatar Dec 04 '11 20:12 h3h

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?

kevinelliott avatar Dec 14 '11 02:12 kevinelliott

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

venkatd avatar Jul 12 '12 19:07 venkatd