Module: Shrine::Plugins::Derivatives::AttacherClassMethods
- Defined in:
- lib/shrine/plugins/derivatives.rb
Instance Method Summary collapse
-
#derivatives_processor(name = :default, &block) ⇒ Object
(also: #derivatives)
Registers a derivatives processor on the attacher class.
-
#derivatives_storage(storage_key = nil, &block) ⇒ Object
Specifies default storage to which derivatives will be uploaded.
Instance Method Details
#derivatives_processor(name = :default, &block) ⇒ Object Also known as: derivatives
Registers a derivatives processor on the attacher class.
Attacher.derivatives_processor :thumbnails do |original|
# ...
end
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shrine/plugins/derivatives.rb', line 55 def derivatives_processor(name = :default, &block) if block shrine_class.opts[:derivatives][:processors][name.to_sym] = block else processor = shrine_class.opts[:derivatives][:processors][name.to_sym] processor ||= NOOP_PROCESSOR if name == :default fail Error, "derivatives processor #{name.inspect} not registered" unless processor processor end end |
#derivatives_storage(storage_key = nil, &block) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/shrine/plugins/derivatives.rb', line 80 def derivatives_storage(storage_key = nil, &block) if storage_key || block shrine_class.opts[:derivatives][:storage] = storage_key || block else shrine_class.opts[:derivatives][:storage] end end |