module Rabl
Constants
- VERSION
Public Class Methods
configuration()
click to toggle source
Returns the configuration options set for RABL ::configuration.include_json_root => false
# File lib/rabl.rb, line 47 def configuration @_configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
Yields a RABL configuration block ::configure do |config|
config.include_json_root = false config.enable_json_callbacks = true
end
# File lib/rabl.rb, line 40 def configure(&block) yield(configuration) configuration end
register!()
click to toggle source
Initialize RABL within an application ::register!
# File lib/rabl.rb, line 31 def register! require 'rabl/template' end
render(object, source, options = {})
click to toggle source
Renders an object using a specified template within an application. render(@post, 'posts/show', :view_path => “/path/to/app/views”)
# File lib/rabl.rb, line 76 def render(object, source, options = {}) Rabl::Renderer.new(source, object, options).render end
reset_configuration!()
click to toggle source
Resets the RABL configuration back to the defaults.
# File lib/rabl.rb, line 52 def reset_configuration! @_configuration = nil end
reset_source_cache!()
click to toggle source
Resets the RABL source cache
# File lib/rabl.rb, line 70 def reset_source_cache! @_source_cache = {} end
source_cache(file, view_path) { || ... }
click to toggle source
Fetches from the ::source_cache, stores block result in cache if nil Used to cache the contents and paths to various rabl templates ::source_cache(“users/index”, “path/to/view”) { “/full/path/to/template/users/index” }
# File lib/rabl.rb, line 59 def source_cache(file, view_path, &block) return yield unless Rabl.configuration.cache_sources cache_key = [file, view_path].compact.join(":") @_source_cache ||= {} @_source_cache[cache_key] ||= yield end