Module: Gluttonberg::Library::AttachmentMixin::ClassMethods

Defined in:
lib/gluttonberg/library/attachment_mixin.rb

Instance Method Summary collapse

Instance Method Details

#generate_nameObject

Generate auto titles for those assets without name



43
44
45
46
47
48
49
50
51
# File 'lib/gluttonberg/library/attachment_mixin.rb', line 43

def generate_name
  assets = Asset.find(:all , :conditions => { :name => "" } )
  assets.each do |asset|
    p asset.file_name
    asset.name = asset.file_name.split(".")[0]
    asset.save
  end
  'done' # this just makes the output nicer when running from slice -i
end

#initialize_storageObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/gluttonberg/library/attachment_mixin.rb', line 30

def initialize_storage
  storage_class_name = Rails.configuration.asset_storage.to_s.downcase.camelize
  begin
    storage_module = Gluttonberg::Library::Storage.const_get(storage_class_name)
  rescue NameError
    raise Exception, "Cannot load storage module '#{storage_class_name}'"
  end
  include(storage_module.const_get("InstanceMethods"))
  extend(storage_module.const_get("ClassMethods"))
end