Method: Kiss::Model#method_missing

Defined in:
lib/kiss/model.rb

#method_missing(meth, *args, &block) ⇒ Object

Raises:

  • (NoMethodError)


203
204
205
206
207
208
209
210
211
212
# File 'lib/kiss/model.rb', line 203

def method_missing(meth, *args, &block)
  if meth.to_s =~ /(\w+)\?\Z/
    column = $1.to_sym
    if respond_to?(column)
      val = self.send(column, *args, &block)
      return !(val.nil? || val.zero?)
    end
  end
  raise NoMethodError, "undefined method `#{meth}' for database model `#{self.class.name.pluralize}'"
end