Sha256: 81c49efaa703e7a487b952aa6a194ecaa2c32d30b6573b4daefa5f7915a9109b
Contents?: true
Size: 874 Bytes
Versions: 10
Compression:
Stored size: 874 Bytes
Contents
module EnjuCirculation module EnjuBasket extend ActiveSupport::Concern included do has_many :checked_items, dependent: :destroy has_many :items, through: :checked_items has_many :checkouts has_many :checkins end def basket_checkout(librarian) return nil if checked_items.size == 0 Item.transaction do checked_items.each do |checked_item| checkout = user.checkouts.new checkout.librarian = librarian checkout.item = checked_item.item checkout.basket = self checkout.library = librarian.profile.library checkout.shelf = checked_item.item.shelf checkout.due_date = checked_item.due_date checked_item.item.checkout!(user) checkout.save! end CheckedItem.destroy_all(basket_id: id) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems