2012-02-22 18:14:00 +00:00
|
|
|
require 'rails/railtie'
|
|
|
|
|
|
|
|
require 'active_support'
|
|
|
|
require 'active_support/core_ext/class/attribute_accessors'
|
|
|
|
|
2012-04-20 14:28:34 +00:00
|
|
|
require 'rabl-rails/version'
|
|
|
|
require 'rabl-rails/template'
|
2012-09-05 16:11:23 +00:00
|
|
|
require 'rabl-rails/condition'
|
2012-04-20 14:28:34 +00:00
|
|
|
require 'rabl-rails/compiler'
|
2012-04-09 23:03:07 +00:00
|
|
|
|
2012-04-20 14:28:34 +00:00
|
|
|
require 'rabl-rails/renderer'
|
2012-04-09 23:03:07 +00:00
|
|
|
|
2012-04-20 14:28:34 +00:00
|
|
|
require 'rabl-rails/library'
|
|
|
|
require 'rabl-rails/handler'
|
|
|
|
require 'rabl-rails/railtie'
|
2012-02-22 18:14:00 +00:00
|
|
|
|
2012-07-18 21:42:09 +00:00
|
|
|
require 'multi_json'
|
2012-04-09 23:03:07 +00:00
|
|
|
|
2012-04-20 14:28:34 +00:00
|
|
|
module RablRails
|
2012-07-25 17:22:10 +00:00
|
|
|
extend Renderer
|
2012-09-05 16:11:23 +00:00
|
|
|
|
2012-04-02 14:22:43 +00:00
|
|
|
mattr_accessor :cache_templates
|
|
|
|
@@cache_templates = true
|
2012-09-05 16:11:23 +00:00
|
|
|
|
2012-07-13 17:15:04 +00:00
|
|
|
mattr_accessor :include_json_root
|
|
|
|
@@include_json_root = true
|
2012-04-02 14:22:43 +00:00
|
|
|
|
2012-08-03 13:38:43 +00:00
|
|
|
mattr_reader :json_engine
|
2012-07-18 21:42:09 +00:00
|
|
|
@@json_engine = :yajl
|
|
|
|
|
|
|
|
def self.configure
|
2012-04-02 14:22:43 +00:00
|
|
|
yield self
|
|
|
|
end
|
2012-09-05 16:11:23 +00:00
|
|
|
|
2012-08-03 13:38:43 +00:00
|
|
|
def self.json_engine=(name)
|
|
|
|
MultiJson.engine = name
|
|
|
|
@@json_engine = name
|
|
|
|
rescue LoadError
|
|
|
|
Rails.logger.warn %Q(WARNING: rabl-rails could not load "#{self.json_engine}" as JSON engine, fallback to default)
|
|
|
|
end
|
2012-09-05 16:11:23 +00:00
|
|
|
|
2012-07-18 21:42:09 +00:00
|
|
|
def self.cache_templates?
|
2012-04-02 14:22:43 +00:00
|
|
|
ActionController::Base.perform_caching && @@cache_templates
|
|
|
|
end
|
2012-09-05 16:11:23 +00:00
|
|
|
|
2012-08-03 13:38:43 +00:00
|
|
|
def self.load_default_engines!
|
|
|
|
self.json_engine = :yajl
|
2012-07-18 21:42:09 +00:00
|
|
|
end
|
2012-02-22 10:42:38 +00:00
|
|
|
end
|