Sha256: 964949cbbaeab6126e9e078402ce91fbf5556017bb9a6c2c365b6f291c14a9a4

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'rack/cache'
require 'dragonfly'

app = Dragonfly[:images]
app.configure_with(:imagemagick)
app.configure_with(:rails)

if defined? ActiveRecord::Base
  app.define_macro(ActiveRecord::Base, :image_accessor)
end

if defined? Mongoid::Document
  require 'mongoid'

  mongo_yml_path  = Rails.env.test? ? "#{File.expand_path('../../../../test/dummy/config', __FILE__)}" : "config"
  yaml_file       = YAML.load_file(File.join(mongo_yml_path, 'mongoid.yml'))[Rails.env]

  app.datastore = Dragonfly::DataStorage::MongoDataStore.new
  app.datastore.configure do |c|
    c.host      = yaml_file['host'] || yaml_file['uri'] # defaults to localhost
    c.port      = yaml_file['port']                     # defaults to mongo default (27017)
    c.database  = yaml_file['database']                 # defaults to 'dragonfly'
    c.username  = yaml_file['username']                 # only needed if mongo is running in auth mode
    c.password  = yaml_file['password']                 # only needed if mongo is running in auth mode
  end

  app.define_macro_on_include(Mongoid::Document, :image_accessor)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attachment_magick-0.3.4 lib/attachment_magick/dragonfly/init.rb