Class: ActiveStorage::NamedVariant

Inherits:
Object
  • Object
show all
Defined in:
app/models/active_storage/named_variant.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transformations) ⇒ NamedVariant

Returns a new instance of NamedVariant.



6
7
8
9
# File 'app/models/active_storage/named_variant.rb', line 6

def initialize(transformations)
  @preprocessed = transformations[:preprocessed]
  @transformations = transformations.except(:preprocessed)
end

Instance Attribute Details

#preprocessedObject (readonly)

Returns the value of attribute preprocessed.



4
5
6
# File 'app/models/active_storage/named_variant.rb', line 4

def preprocessed
  @preprocessed
end

#transformationsObject (readonly)

Returns the value of attribute transformations.



4
5
6
# File 'app/models/active_storage/named_variant.rb', line 4

def transformations
  @transformations
end

Instance Method Details

#preprocessed?(record) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
# File 'app/models/active_storage/named_variant.rb', line 11

def preprocessed?(record)
  case preprocessed
  when Symbol
    record.send(preprocessed)
  when Proc
    preprocessed.call(record)
  else
    preprocessed
  end
end