Class: Item
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Item
- Defined in:
- app/models/item.rb,
app/models2/item.rb
Instance Attribute Summary collapse
-
#library_id ⇒ Object
Returns the value of attribute library_id.
Class Method Summary collapse
Instance Method Summary collapse
- #contributor ⇒ Object
- #creator ⇒ Object
- #manifestation_url ⇒ Object
- #owned(agent) ⇒ Object
- #publisher ⇒ Object
- #removable? ⇒ Boolean
- #title ⇒ Object
- #to_hash(role: 'Guest') ⇒ Object
Instance Attribute Details
#library_id ⇒ Object
Returns the value of attribute library_id.
64 65 66 |
# File 'app/models/item.rb', line 64 def library_id @library_id end |
Class Method Details
Instance Method Details
#contributor ⇒ Object
76 77 78 |
# File 'app/models/item.rb', line 76 def contributor manifestation&.contributor end |
#creator ⇒ Object
72 73 74 |
# File 'app/models/item.rb', line 72 def creator manifestation&.creator end |
#manifestation_url ⇒ Object
88 89 90 |
# File 'app/models/item.rb', line 88 def manifestation_url Addressable::URI.parse("#{LibraryGroup.site_config.url}manifestations/#{self.manifestation.id}").normalize.to_s if self.manifestation end |
#owned(agent) ⇒ Object
84 85 86 |
# File 'app/models/item.rb', line 84 def owned(agent) owns.find_by(agent_id: agent.id) end |
#publisher ⇒ Object
80 81 82 |
# File 'app/models/item.rb', line 80 def publisher manifestation&.publisher end |
#removable? ⇒ Boolean
92 93 94 95 96 97 98 99 100 |
# File 'app/models/item.rb', line 92 def removable? if defined?(EnjuCirculation) return false if circulation_status.name == 'Removed' return false if checkouts.exists? true else true end end |
#title ⇒ Object
68 69 70 |
# File 'app/models/item.rb', line 68 def title manifestation&.original_title end |
#to_hash(role: 'Guest') ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/models/item.rb', line 106 def to_hash(role: 'Guest') record = { item_id: id, item_identifier: item_identifier, binding_item_identifier: binding_item_identifier, call_number: call_number, library: shelf&.library&.name, shelf: shelf&.name, item_note: note, accepted_at: accept&.created_at, acquired_at: acquired_at, item_created_at: created_at, item_updated_at: updated_at } if ['Administrator', 'Librarian'].include?(role) record.merge!({ bookstore: bookstore&.name, budget_type: budget_type&.name, item_required_role: required_role.name, item_price: price, item_memo: memo }) ItemCustomProperty.order(:position).each do |custom_property| custom_value = item_custom_values.find_by(item_custom_property: custom_property) record[:"item:#{custom_property.name}"] = custom_value.try(:value) end if defined?(EnjuCirculation) record.merge!({ use_restriction: use_restriction&.name, circulation_status: circulation_status&.name, checkout_type: checkout_type&.name, total_checkouts: checkouts.count }) end end record end |