Skip to content

Reserved Method Names

KevinTriplett edited this page Aug 26, 2011 · 2 revisions

These names are used by in the Apotomo::Widget base class as method names:

  • #process
  • #add
  • #invoke
  • #replace
  • #update
  • #trigger
  • #sort
  • #inject
  • #reduce

And many others. Vague method names in your widget classes might conflict with methods in Apotomo::Widget, so best practice is to name your methods with descriptive names. If you run into strange errors in your widget methods, take a look and see if it's caused by a method name conflict.

This does not fall under reserved method names, but keep in mind that when scoping your widgets, you cannot call your widgets the same as an association class. For instance:

class User < ActiveRecord::Base
  has_many :phones
end

class Phone < ActiveRecord::Base
  belongs_to :user
end

class User::PhoneWidget < ::Apotomo::Widget
  ...
end

This will fail with the strange error 'undefined method 'quoted_table_name' for User::Phone:Module`. The solution is to rename your widget:

class User::PhonesWidget < ::Apotomo::Widget
  ...
end