Sha256: a6da8587c55e9f9b1d862e93011d316c2ed1509d3076dbe07ddcce07cef3efcc

Contents?: true

Size: 799 Bytes

Versions: 9

Compression:

Stored size: 799 Bytes

Contents

# encoding: utf-8
module RailsBestPractices
  module Core
    class ModelAssociations
      def initialize
        @associations = {}
      end

      def add_association(model_name, association_name, association_meta, association_class=nil)
        @associations[model_name] ||= {}
        @associations[model_name][association_name] = {:meta => association_meta, :class_name => association_class || association_name.classify}
      end

      def get_association(model_name, association_name)
        associations = @associations[model_name]
        associations and associations[association_name]
      end

      def is_association?(model_name, association_name)
        associations = @associations[model_name]
        associations && associations[association_name]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
rails_best_practices-0.10.1 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.10.0 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-raydog153-0.9.1 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.9.0 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.8.2 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.8.1 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.8.0 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.7.5 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-0.7.4 lib/rails_best_practices/core/model_associations.rb