Module: Shared::Depictions

Extended by:
ActiveSupport::Concern
Included in:
CharacterState, CollectingEvent, CollectionObject, CollectionObjectObservation, Content, Label, Loan, Otu
Defined in:
app/models/concerns/shared/depictions.rb

Overview

Shared code for extending data-classes with Depictions.

Instance Method Summary collapse

Instance Method Details

#has_depictions?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/concerns/shared/depictions.rb', line 17

def has_depictions?
  self.depictions.size > 0
end

#image_array=(images) ⇒ Object



21
22
23
# File 'app/models/concerns/shared/depictions.rb', line 21

def image_array=(images)
  self.depictions_attributes = images.collect{|i, file| { image_attributes: {image_file: file}}}
end

#reject_depictions(attributed) ⇒ Object (protected)

Not tested!



28
29
30
# File 'app/models/concerns/shared/depictions.rb', line 28

def reject_depictions(attributed)
  attributed['image_attributes'].blank? ||  attributed['image_attributes']['image_file'].blank?
end

#reject_images(attributed) ⇒ Object (protected)



32
33
34
# File 'app/models/concerns/shared/depictions.rb', line 32

def reject_images(attributed)
  attributed['image_file'].blank? 
end