Sha256: 0b478d8ff87e780f031e44aac7259140a6573032e47af3b5f01ebebfc41da905

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

module EnjuCirculation
  module EnjuWithdraw
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def enju_circulation_withdraw_model
        include InstanceMethods
        before_save :withdraw!, on: :create
      end
    end

    module InstanceMethods
      def withdraw!
        circulation_status = CirculationStatus.where(name: 'Removed').first
        item.update_column(:circulation_status_id, circulation_status.id) if circulation_status
        item.use_restriction = UseRestriction.where(name: 'Not For Loan').first
        item.index!
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enju_circulation-0.1.2 lib/enju_circulation/withdraw.rb
enju_circulation-0.1.1 lib/enju_circulation/withdraw.rb
enju_circulation-0.1.0 lib/enju_circulation/withdraw.rb
enju_circulation-0.1.0.pre49 lib/enju_circulation/withdraw.rb