Module Rabl::Helpers
In: lib/rabl/helpers.rb

Methods

Classes and Modules

Module Rabl::Helpers::Escaper

Public Instance methods

Returns the root for the collection Sets the name of the collection i.e "people"

 => { "people" : [] }

Returns the context_scope wrapping this engine, used for retrieving data, invoking methods, etc In Rails, this is the controller and in Padrino this is the request context

data_name(data) => "user" data_name(@user => :person) => :person data_name(@users) => :user data_name([@user]) => "users" data_name([]) => "array"

data_object(data) => <AR Object> data_object(@user => :person) => @user data_object(:user => :person) => @_object.send(:user)

Returns the object rootname based on if the root should be included Can be called with data as a collection or object determine_object_root(@user, :user, true) => "user" determine_object_root(@user, :person) => "person" determine_object_root([@user, @user]) => "user"

Fetches a key from the cache and stores rabl template result otherwise fetch_from_cache(‘some_key’) { …rabl template result… }

Returns true if the obj is a collection of items is_collection?(@user) => false is_collection?([]) => true

Returns true if the value is a name value (symbol or string)

Returns true if obj is not a collection is_object?(@user) => true is_object?([]) => false is_object?({}) => false

Returns the root (if any) name for an object within a collection Sets the name of the object i.e "person"

> { "users" : [{ "person" : {} }] }

Returns an Engine based representation of any data object given ejs template block object_to_engine(@user) { attribute :full_name } => { … } object_to_engine(@user, :source => "…") { attribute :full_name } => { … } object_to_engine([@user], :source => "…") { attribute :full_name } => { … } options must have :source (rabl file contents) options can have :source_location (source filename)

Returns true if the cache has been enabled for the application

[Validate]