forked from ruport/ruport
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for r385, inspired by Brian's implementation
git-svn-id: http://stonecode.svnrepository.com/svn/ruport/ruport/trunk@1292 bb2e8eb0-7117-0410-aac4-c024b40ed5f7
- Loading branch information
sandal
committed
Mar 31, 2008
1 parent
96fdb86
commit bc1b6e8
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Demonstrates building a parent controller which provides additional 'built in' | ||
# formats, allowing anonymous formatter support to use the simple interface | ||
# rather than the :format => FormatterClass approach. | ||
|
||
require "ruport" | ||
module FooCorp | ||
class Controller < Ruport::Controller | ||
def self.built_in_formats | ||
super.merge(:xml => FooCorp::Formatter::XML) | ||
end | ||
end | ||
|
||
class Formatter | ||
class XML < Ruport::Formatter | ||
|
||
def xmlify(stuff) | ||
output << "Wouldn't you like to see #{stuff} in XML?" | ||
end | ||
end | ||
end | ||
|
||
class MyController < FooCorp::Controller | ||
stage :foo | ||
|
||
formatter :xml do | ||
build :foo do | ||
xmlify "Red Snapper" | ||
end | ||
end | ||
|
||
formatter :text do | ||
build :foo do | ||
output << "Red Snapper" | ||
end | ||
end | ||
end | ||
end | ||
|
||
puts "XML:" | ||
puts FooCorp::MyController.render_xml | ||
|
||
puts "Text:" | ||
puts FooCorp::MyController.render_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters