lib - part of load path
install.rb/uninstall.rb - only evaluated once (script plugin)
Pros and cons
Speaker is author of engine plugins
DRY that can be shared
Plugins are a bout Ruby
Example - add copyright function to all plugins
step one - use include module at the beginning of class
step two - use include in ActiveRecord::Base
step three - AR::Base.send( :include, Module ) [will be disallowed in Ruby 2]
include does not add class method; therefor add class method, then extend the class with the class methods module
include+extend -> use self.included to include class method module; call class_eval and do extend within it
this is what plugins are all about!!
Plugins are sanction method to change Rails
a module is inserted above a class, and below the superclass - does not override class behaviour
redefine methods of a class - don't do this!
in Rails - use alias_method_chain (this isn't very simple, but very convenient)
Engine plugin adds to Dependencies class
Example validates_ in AR
Like attr_accessor in Ruby classes - not a keyword, it's a method
You can call any class method in the class definition!!
Make method into module, then extend ActiveRecord::Base, and you can use it in class definition