def add_hook
      if [:has_one, :belongs_to].include?(type)
        HasOneHook.new(model, association_name).attach
      else
        HasManyHook.new(model, association_name, options).attach
      end
    end
def add_hook
      if [:has_one, :belongs_to].include?(type)
        HasOneHook.new(model, association_name).attach
      else
        HasManyHook.new(model, association_name, options).attach
      end
    end
Public: Creates a new Association.

 model - The ActiveRecord model (not the instance!).
 association_name - Name of the association you will want to
                    add the callback to.
 options - The Hash options used to the number of
           records (default = {}):
           :count  - An Integer that specifies the number of
                     records to create.
           :append - Boolean, defines if you only want one record
                     at the end of the array. False by default.
                     Equivalent to :count => 1.

 `has_one` associations **don't** receive any options.

 For `has_many` associations, if the user doesn't pass any options,
 the default will be to add one new record if no other records
 exist yet.

 Examples

   Association.new(User, :photo)

   Association.new(User, :projects, :append => true)

   Association.new(User, :projects, :count => 3)

   Association.new(user, :photo)
   # => Error! You want to pass the class, no the instance

 Raises AutoBuildError if you pass the :count and :append options
 at the same time.
 Public: Adds the callback to the objects.

 It will choose the correct hook based on the value of `type`.