engine/lib/locomotive.rb

59 lines
1.3 KiB
Ruby
Raw Normal View History

2010-04-22 23:52:11 +00:00
# require 'locomotive/patches'
require 'locomotive/configuration'
2010-06-14 13:04:01 +00:00
require 'locomotive/logger'
require 'locomotive/liquid'
require 'locomotive/mongoid'
require 'locomotive/carrierwave'
2010-06-14 13:04:01 +00:00
require 'locomotive/heroku'
require 'locomotive/custom_fields'
require 'locomotive/httparty'
require 'locomotive/inherited_resources'
require 'locomotive/admin_responder'
2010-07-29 23:21:48 +00:00
require 'locomotive/routing'
require 'locomotive/regexps'
require 'locomotive/render'
2010-04-22 23:52:11 +00:00
require 'mongo_session_store/mongoid'
module Locomotive
2010-06-14 13:04:01 +00:00
include Locomotive::Heroku
class << self
attr_accessor :config
def config
self.config = Configuration.new unless @config
@config
end
end
def self.configure
self.config ||= Configuration.new
yield(self.config)
2010-06-03 15:32:40 +00:00
after_configure
end
2010-06-03 15:32:40 +00:00
def self.after_configure
raise '[Error] Locomotive needs a default domain name' if Locomotive.config.default_domain.blank?
2010-06-14 13:04:01 +00:00
ActionMailer::Base.default_url_options[:host] = self.config.default_domain + (Rails.env.development? ? ':3000' : '')
2010-06-03 15:32:40 +00:00
# cookies stored in mongodb (mongoid_store)
Rails.application.config.session_store :mongoid_store, {
:key => Locomotive.config.cookie_key
2010-06-03 15:32:40 +00:00
}
2010-06-14 13:04:01 +00:00
# Heroku support
self.enable_heroku if self.heroku?
end
2010-06-14 13:04:01 +00:00
def self.logger(message)
if Locomotive.config.enable_logs == true
Rails.logger.info(message)
end
2010-06-03 15:32:40 +00:00
end
end