Add root in DSL
This commit is contained in:
parent
9f0a92ecd7
commit
a97a8cd24f
@ -1,6 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## 0.2.0 (unrelased)
|
## 0.2.0 (unrelased)
|
||||||
|
* Add `root` in DSL to set root without changing the source
|
||||||
* Add XML renderer
|
* Add XML renderer
|
||||||
* Use MultiJson's preferred JSON engine as default (shmeltex)
|
* Use MultiJson's preferred JSON engine as default (shmeltex)
|
||||||
* Default template to render with responder can be set per controller
|
* Default template to render with responder can be set per controller
|
||||||
|
@ -30,6 +30,10 @@ module RablRails
|
|||||||
end
|
end
|
||||||
alias_method :collection, :object
|
alias_method :collection, :object
|
||||||
|
|
||||||
|
def root(name)
|
||||||
|
@template.root_name = name
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Includes the attribute or method in the output
|
# Includes the attribute or method in the output
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -24,6 +24,16 @@ class CompilerTest < ActiveSupport::TestCase
|
|||||||
assert_equal({}, t.source)
|
assert_equal({}, t.source)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "root can be defined via keyword" do
|
||||||
|
t = @compiler.compile_source(%{ root :author })
|
||||||
|
assert_equal :author, t.root_name
|
||||||
|
end
|
||||||
|
|
||||||
|
test "root keyword override object root" do
|
||||||
|
t = @compiler.compile_source(%{ object :@user ; root :author })
|
||||||
|
assert_equal :author, t.root_name
|
||||||
|
end
|
||||||
|
|
||||||
test "collection set the data for the template" do
|
test "collection set the data for the template" do
|
||||||
t = @compiler.compile_source(%{ collection :@user })
|
t = @compiler.compile_source(%{ collection :@user })
|
||||||
assert_equal :@user, t.data
|
assert_equal :@user, t.data
|
||||||
|
Loading…
Reference in New Issue
Block a user