# Copyright 2008 Wincent Colaiuta
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 'wikitext'

class NilClass
  def to_wikitext
    ''
  end
  alias :w :to_wikitext
end

Add convenience methods to NilClass
Add convenience methods to NilClass

Like the methods added to String, these are only added if the user
explicitly requires 'wikitext/nil_class'. They add a "w" and a
"to_wikitext" method to the NilClass.

This in turn enables code which might look like this:

  body = @article.body
  body.nil? ? '' : body.w

To simply be written as:

  @article.body.w

Signed-off-by: Wincent Colaiuta <c76ac2e9cd86441713c7dfae92c451f3e6d17fdc@wincent.com>
