Module | Rabl::Helpers |
In: |
lib/rabl/helpers.rb
|
Returns the root for the collection Sets the name of the collection i.e "people"
=> { "people" : [] }
Returns the 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_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, 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 obj is not a collection is_object?(@user) => true is_object?([]) => false is_object?({}) => false