Class: Rabl::Builder
Constant Summary collapse
- SETTING_TYPES =
{ :extends => :file, :node => :name, :child => :data, :glue => :data }
Constants included from Helpers
Instance Method Summary collapse
-
#build(object, options = {}) ⇒ Object
Given an object and options, returns the hash representation build(@user, :format => “json”, :attributes => { … }, :root_name => “user”).
-
#initialize(options = {}, &block) ⇒ Builder
constructor
Constructs a new rabl hash based on given object and options options = { :format => “json”, :root => true, :child_root => true, :attributes, :node, :child, :glue, :extends }.
Methods included from Partials
#fetch_source, #object_to_hash, #partial
Methods included from Helpers
#collection_root_name, #context_scope, #data_name, #data_object, #data_object_attribute, #determine_object_root, #fetch_result_from_cache, #is_collection?, #is_name_value?, #is_object?, #object_root_name, #template_cache_configured?
Constructor Details
#initialize(options = {}, &block) ⇒ Builder
Constructs a new rabl hash based on given object and options options = { :format => “json”, :root => true, :child_root => true,
:attributes, :node, :child, :glue, :extends }
16 17 18 19 20 |
# File 'lib/rabl/builder.rb', line 16 def initialize(={}, &block) @options = @_scope = [:scope] @_view_path = [:view_path] end |
Instance Method Details
#build(object, options = {}) ⇒ Object
Given an object and options, returns the hash representation build(@user, :format => “json”, :attributes => { … }, :root_name => “user”)
24 25 26 27 28 29 30 |
# File 'lib/rabl/builder.rb', line 24 def build(object, ={}) @_object = object cache_results do compile_hash() end end |