Module: Redde::WithPhoto
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/redde/with_photo.rb
Constant Summary collapse
- QUERY =
'imageable_id = :id AND imageable_type = :type OR token in (:tokens)'.freeze
Instance Method Summary collapse
Instance Method Details
#all_photos ⇒ Object
12 13 14 |
# File 'app/models/concerns/redde/with_photo.rb', line 12 def all_photos Redde::Photo.where(QUERY, id: id, type: self.class.name, tokens: tokens) end |
#assign_photos ⇒ Object
16 17 18 |
# File 'app/models/concerns/redde/with_photo.rb', line 16 def assign_photos Redde::Photo.where(token: tokens).update_all(imageable_attributes) end |
#imageable_attributes ⇒ Object
20 21 22 |
# File 'app/models/concerns/redde/with_photo.rb', line 20 def imageable_attributes { imageable_id: id, imageable_type: self.class.name, token: nil } end |
#tokens ⇒ Object
24 25 26 |
# File 'app/models/concerns/redde/with_photo.rb', line 24 def tokens photo_tokens || [] end |