rabl 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -175,6 +175,25 @@ You can also extend other rabl templates while constructing child nodes to reduc
175
175
 
176
176
  Using partials and inheritance can significantly reduce code duplication in your templates.
177
177
 
178
+ ### Deep Nesting ###
179
+
180
+ In APIs, you can often need to construct 2nd or 3rd level nodes. Let's suppose we have a 'quiz' model that has many 'questions'
181
+ and then each question has many 'answers'. We can display this hierarchy in RABL quite easily:
182
+
183
+ # app/views/quizzes/show.json.rabl
184
+ object @quiz
185
+ attribute :title
186
+ child :questions do
187
+ attribute :caption
188
+ child :answers do
189
+ # Use inheritance to reduce duplication
190
+ extends "answers/item"
191
+ end
192
+ end
193
+
194
+ This will display the quiz object with nested questions and answers as you would expect with a quiz node, and embedded questions and answers.
195
+ Note that RABL can be nested arbitrarily deep within child nodes to allow for these representations to be defined.
196
+
178
197
  ## Issues ##
179
198
 
180
199
  Check out the [Issues](https://github.com/nesquena/rabl/issues) tab for a full list:
data/lib/rabl/template.rb CHANGED
@@ -7,7 +7,7 @@ if defined?(Tilt)
7
7
  end
8
8
 
9
9
  def prepare
10
- options = @options.merge(:format => "json")
10
+ options = @options.merge(:format => @options[:format])
11
11
  @engine = ::Rabl::Engine.new(data, options)
12
12
  end
13
13
 
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Esquenazi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-19 00:00:00 -07:00
13
+ date: 2011-04-20 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency