Sha256: 8476130aa3b6ebc0bfc2ee07dadfe3f38c2e6e12e96e0d9eb6201d51854ed15f

Contents?: true

Size: 749 Bytes

Versions: 40

Compression:

Stored size: 749 Bytes

Contents

module EnjuLibrary
  module EnjuItem
    extend ActiveSupport::Concern

    included do
      has_one :accept
      scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}

      belongs_to :shelf, counter_cache: true, validate: true
      validates_associated :shelf

      searchable do
        string :library do
          shelf.library.name if shelf
        end
      end
    end

    def shelf_name
      shelf.name
    end

    def hold?(library)
      return true if shelf.library == library
      false
    end

    def library_url
      "#{LibraryGroup.site_config.url}libraries/#{shelf.library.name}"
    end
  end
end

Version data entries

40 entries across 38 versions & 2 rubygems

Version Path
enju_library-0.3.11 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.10 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.9 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.8 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.8.rc.2 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.8.rc.1 app/models/concerns/enju_library/enju_item.rb
enju_library-0.4.0.rc.1 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.7 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.6 app/models/concerns/enju_library/enju_item.rb
enju_library-0.4.0.beta.4 app/models/concerns/enju_library/enju_item.rb
enju_library-0.4.0.beta.3 app/models/concerns/enju_library/enju_item.rb
enju_library-0.4.0.beta.2 app/models/concerns/enju_library/enju_item.rb
enju_library-0.4.0.beta.1 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.5 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.4 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.3 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.2 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.1 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.0 app/models/concerns/enju_library/enju_item.rb
enju_library-0.3.0.rc.1 app/models/concerns/enju_library/enju_item.rb