Sha256: 06fa356edc0795897dfd8b3db399d075ac429596df59f8fa1794ecc7564967bb

Contents?: true

Size: 1.13 KB

Versions: 61

Compression:

Stored size: 1.13 KB

Contents

class Exemplify < ActiveRecord::Base
  belongs_to :manifestation
  belongs_to :item

  validates_associated :manifestation, :item
  validates_presence_of :manifestation_id, :item_id
  validates_uniqueness_of :item_id
  after_save :reindex
  after_destroy :reindex

  acts_as_list :scope => :manifestation_id

  def self.per_page
    10
  end

  def reindex
    manifestation.try(:index)
    item.try(:index)
  end

  if defined?(EnjuCirculation)
    after_create :create_lending_policy

    def create_lending_policy
      UserGroupHasCheckoutType.available_for_item(item).each do |rule|
        LendingPolicy.create!(:item_id => item.id, :user_group_id => rule.user_group_id, :fixed_due_date => rule.fixed_due_date, :loan_period => rule.checkout_period, :renewal => rule.checkout_renewal_limit)
      end
    end
  end
end

# == Schema Information
#
# Table name: exemplifies
#
#  id               :integer         not null, primary key
#  manifestation_id :integer         not null
#  item_id          :integer         not null
#  type             :string(255)
#  position         :integer
#  created_at       :datetime
#  updated_at       :datetime
#

Version data entries

61 entries across 61 versions & 3 rubygems

Version Path
enju_circulation-0.0.19 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.18 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.17 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.16 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.15 spec/dummy/app/models/exemplify.rb
enju_bookmark-0.0.7 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.14 spec/dummy/app/models/exemplify.rb
enju_bookmark-0.0.6 spec/dummy/app/models/exemplify.rb
enju_bookmark-0.0.5 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.13 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.12 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.11 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.10 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.9 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.8 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.7 spec/dummy/app/models/exemplify.rb
enju_bookmark-0.0.4 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.6 spec/dummy/app/models/exemplify.rb
enju_bookmark-0.0.3 spec/dummy/app/models/exemplify.rb
enju_circulation-0.0.4 spec/dummy/app/models/exemplify.rb