Class: ActiveStorage::VariantWithRecord
- Inherits:
-
Object
- Object
- ActiveStorage::VariantWithRecord
- Defined in:
- app/models/active_storage/variant_with_record.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
readonly
Returns the value of attribute blob.
-
#variation ⇒ Object
readonly
Returns the value of attribute variation.
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(blob, variation) ⇒ VariantWithRecord
constructor
A new instance of VariantWithRecord.
- #process ⇒ Object
- #processed ⇒ Object
- #processed? ⇒ Boolean
Constructor Details
#initialize(blob, variation) ⇒ VariantWithRecord
Returns a new instance of VariantWithRecord.
6 7 8 |
# File 'app/models/active_storage/variant_with_record.rb', line 6 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end |
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob.
4 5 6 |
# File 'app/models/active_storage/variant_with_record.rb', line 4 def blob @blob end |
#variation ⇒ Object (readonly)
Returns the value of attribute variation.
4 5 6 |
# File 'app/models/active_storage/variant_with_record.rb', line 4 def variation @variation end |
Instance Method Details
#image ⇒ Object
23 24 25 |
# File 'app/models/active_storage/variant_with_record.rb', line 23 def image record&.image end |
#process ⇒ Object
15 16 17 |
# File 'app/models/active_storage/variant_with_record.rb', line 15 def process transform_blob { |image| create_or_find_record(image: image) } unless processed? end |
#processed ⇒ Object
10 11 12 13 |
# File 'app/models/active_storage/variant_with_record.rb', line 10 def processed process self end |
#processed? ⇒ Boolean
19 20 21 |
# File 'app/models/active_storage/variant_with_record.rb', line 19 def processed? record.present? end |