Sha256: fa54bf549f071d994989f09729c47b61561f567ec2abec0c66c02d8c25d901d9
Contents?: true
Size: 1.05 KB
Versions: 12
Compression:
Stored size: 1.05 KB
Contents
module EnjuCirculation module EnjuBasket def self.included(base) base.extend ClassMethods end module ClassMethods def enju_circulation_basket_model include InstanceMethods has_many :checked_items, dependent: :destroy has_many :items, through: :checked_items has_many :checkouts has_many :checkins end end module InstanceMethods 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 end
Version data entries
12 entries across 12 versions & 1 rubygems