class Essay::ModelFeatures::CarrierWave
Public Instance Methods
accessor_for(attribute)
click to toggle source
class Article
mount_uploader :poster, PosterUploader, mount_on: :poster_path
end
Article.features.carrierwave.accessor_for(:poster_path) => :poster
# File lib/essay-carrierwave/model.rb, line 91 def accessor_for(attribute) attribute = attribute.to_sym if table.has_key?(attribute) attribute elsif pair = pair_for(attribute) pair.first else send_to_translation(:accessor_for, attribute) end end
options()
click to toggle source
class Article
mount_uploader :poster, PosterUploader, mount_on: :poster_path
end
Article.features.carrierwave.options => { poster: { mount_on: :poster_path } }
# File lib/essay-carrierwave/model.rb, line 66 def options active_record.uploader_options end
table()
click to toggle source
class Article
mount_uploader :poster, PosterUploader
end
Article.features.carrierwave.table => { poster: PosterUploader }
# File lib/essay-carrierwave/model.rb, line 56 def table active_record.uploaders end
uploader_for(attribute)
click to toggle source
class Article
mount_uploader :poster, PosterUploader, mount_on: :poster_path
end
Article.features.carrierwave.uploader_for(:poster_path) => PosterUploader
# File lib/essay-carrierwave/model.rb, line 76 def uploader_for(attribute) if pair = pair_for(attribute.to_sym) table[pair.first] else send_to_translation(:uploader_for, attribute.to_sym) end end
Private Instance Methods
pair_for(mounted_on_or_attr_name)
click to toggle source
# File lib/essay-carrierwave/model.rb, line 111 def pair_for(mounted_on_or_attr_name) all_options = options key = mounted_on_or_attr_name.to_sym if all_options.has_key?(key) {key => all_options[key]} else all_options.find do |name, options| options.is_a?(Hash) && (mount_on = options[:mount_on]) && mount_on.to_sym == key end end end
send_to_translation(method, *args)
click to toggle source
# File lib/essay-carrierwave/model.rb, line 124 def send_to_translation(method, *args) active_record.features.with(:globalize) do |g| g.active_record_for_translations.features.carrierwave.send(method, *args) end end