Module: Paperclip::Helpers
- Included in:
- Paperclip
- Defined in:
- lib/paperclip/helpers.rb
Instance Method Summary collapse
- #class_for(class_name) ⇒ Object
- #configure {|_self| ... } ⇒ Object
-
#each_instance_with_attachment(klass, name) ⇒ Object
Find all instances of the given Active Record model
klasswith attachmentname. - #interpolates(key, &block) ⇒ Object
- #reset_duplicate_clash_check! ⇒ Object
-
#run(command, arguments = nil, interpolation_values = {}, local_options = {}) ⇒ Object
deprecated
Deprecated.
Will be removed in Paperclip 8.0. Use
Paperclip::Commands::Runner.runinstead.
Instance Method Details
#class_for(class_name) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/paperclip/helpers.rb', line 26 def class_for(class_name) class_name.split("::").inject(Object) do |klass, partial_class_name| if klass.const_defined?(partial_class_name) klass.const_get(partial_class_name, false) else klass.const_missing(partial_class_name) end end end |
#configure {|_self| ... } ⇒ Object
5 6 7 |
# File 'lib/paperclip/helpers.rb', line 5 def configure yield(self) if block_given? end |
#each_instance_with_attachment(klass, name) ⇒ Object
Find all instances of the given Active Record model klass with attachment name.
This method is used by the refresh rake tasks.
20 21 22 23 24 |
# File 'lib/paperclip/helpers.rb', line 20 def (klass, name) class_for(klass).unscoped.where("#{name}_file_name IS NOT NULL").find_each do |instance| yield(instance) end end |
#interpolates(key, &block) ⇒ Object
9 10 11 |
# File 'lib/paperclip/helpers.rb', line 9 def interpolates(key, &block) Paperclip::Interpolations[key] = block end |
#reset_duplicate_clash_check! ⇒ Object
36 37 38 |
# File 'lib/paperclip/helpers.rb', line 36 def reset_duplicate_clash_check! @names_url = nil end |
#run(command, arguments = nil, interpolation_values = {}, local_options = {}) ⇒ Object
Deprecated.
Will be removed in Paperclip 8.0. Use Paperclip::Commands::Runner.run instead.
14 15 16 |
# File 'lib/paperclip/helpers.rb', line 14 def run(command, arguments = nil, interpolation_values = {}, = {}) Commands::Runner.run(command, nil, arguments, interpolation_values, ) end |