module MethodWithSave

Constants

VERSION

Public Instance Methods

method_missing(method_name, *args) click to toggle source
Calls superclass method
# File lib/method_with_save.rb, line 4
def method_missing(method_name, *args)
  if /^(.+)_with_save(\!?)$/.match(method_name)
    if defined? $1
      send($1,*args)
      if $2.blank?
        return self.save
      else
        return self.save!
      end
    end
  end

  if /^(.+)_with_save_without_validate(\!?)$/.match(method_name)
    if defined? $1
      send($1,*args)
      if $2.blank?
        return self.save(:validate=>false)
      else
        return self.save!(:validate=>false)
      end
    end
  end
  super
end