Take success or error in as a text and replace the below with:
if type.eql?(''success'')
x.success do
x.message "#{msg}"
end
else
x.error do
x.message "#{msg}"
end
end
Final version:
remove the duplication.
type = "success" or "error"
x.type do
x.message ""
On Fri, Apr 16, 2010 at 11:30, Robert Walker
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Chris Habgood wrote:
> > Is there a way to do something like:
> >
> > x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1)
> > x.instruct!
> > x.response{
> > x.XXXXX{
> >
> > XXXXX is a variable sent in to a method.
>
> Can you clarify? I don''t understand your question.
>
> x.XXXXX { ... } would create an XML tag named "XXXXX"
>
> <?xml version="1.0"?>
> <response>
> <XXXXX>
> ...
> </XXXXX>
> </response>
>
> Attributes are added by passing in a hash x.XXXXX(:title =>
"foo", name
> => "bar") { ... }
>
> <?xml version="1.0"?>
> <response>
> <XXXXX title="foo" name="bar">
> ...
> </XXXXX>
> </response>
>
> What are you actually trying to do?
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.