aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/models/active_storage/variation.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/app/models/active_storage/variation.rb')
-rw-r--r--activestorage/app/models/active_storage/variation.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb
index cf04a879eb..df2643442a 100644
--- a/activestorage/app/models/active_storage/variation.rb
+++ b/activestorage/app/models/active_storage/variation.rb
@@ -13,6 +13,15 @@ class ActiveStorage::Variation
attr_reader :transformations
class << self
+ def wrap(variation_or_key)
+ case variation_or_key
+ when self
+ variation_or_key
+ else
+ decode variation_or_key
+ end
+ end
+
# Returns a variation instance with the transformations that were encoded by +encode+.
def decode(key)
new ActiveStorage.verifier.verify(key, purpose: :variation)