module NegativeMethod

Public Instance Methods

_method_missing(negative_method_name, *args)
Alias for: method_missing
get_positive_method_from(method_name) click to toggle source
# File lib/negative_method.rb, line 13
def get_positive_method_from method_name
  if method_name.match(/^no_/)
    return method_name.sub(/no_/,'')
  elsif method_name.match(/^not_/) || method_name.match(/_not_/)
    return method_name.sub(/not_/,'')
  elsif method_name.match(/_not$/) || method_name.match(/_not?/)
    return method_name.sub(/_not/,'')
  end
end
method_missing(negative_method_name, *args) click to toggle source
# File lib/negative_method.rb, line 3
def method_missing(negative_method_name, *args)

  positive_method = get_positive_method_from negative_method_name.to_s
  if ( positive_method && self.respond_to?(positive_method) )
      return !self.send(positive_method, *args)
  end

  _method_missing negative_method_name, *args
end
Also aliased as: _method_missing