Sha256: 7a7c2af54aa6aec0ad0b64f71f19343fb2fbb3f32603503378ec68ff9507edfd

Contents?: true

Size: 718 Bytes

Versions: 6

Compression:

Stored size: 718 Bytes

Contents

module ConnectionManager
  module Associations
    @defined_associations
    
    # Stores defined associtions and their options
    def defined_associations
      @defined_associations ||= {}
    end
        
    def belongs_to(*options)
      defined_associations[:belongs_to] ||= []
      defined_associations[:belongs_to] << options
      super
    end
    
    def has_many(*options)
      defined_associations[:has_many] ||= []
      defined_associations[:has_many] << options
      super
    end
    
    def has_one(*options)
      defined_associations[:has_one] ||= []
      defined_associations[:has_one] << options
      super
    end   
  end
end
ActiveRecord::Base.extend(ConnectionManager::Associations) 

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
connection_manager-0.1.4 lib/connection_manager/associations.rb
connection_manager-0.1.3 lib/connection_manager/associations.rb
connection_manager-0.1.2 lib/connection_manager/associations.rb
connection_manager-0.1.1 lib/connection_manager/associations.rb
connection_manager-0.1.0 lib/connection_manager/associations.rb
connection_manager-0.0.1 lib/connection_manager/associations.rb