Browse files

configure the Nibbler base parser class

  • Loading branch information...
1 parent be2e638 commit d7ffa8edfb1fba8470c257134ec40243c86a5bb3 @mislav mislav committed Feb 26, 2013
Showing with 8 additions and 2 deletions.
  1. +6 −0 lib/ahora/representation.rb
  2. +2 −2 test/ahora_test.rb
View
6 lib/ahora/representation.rb
@@ -54,6 +54,12 @@ def boolean(*names)
end
private
+
+ # allows using block sub-parsers without explicitly stating they need to
+ # inherit from Ahora::Representation
+ def base_parser_class
+ Representation
+ end
end
extend Definition
View
4 test/ahora_test.rb
@@ -47,11 +47,11 @@ class Post < Ahora::Representation
element './parentObjectId' => :parent_id, :with => lambda {|n| n.content.to_i }
date :created_at
element :body
- element 'user', :with => Ahora::Representation do
+ element 'user' do
string :first_name, :last_name
end
boolean :hidden
- elements 'replies/userPost' => :replies, :with => Post
+ elements 'replies/userPost' => :replies, :with => self
end
class PostDomainRepository < PostRepository

0 comments on commit d7ffa8e

Please sign in to comment.