Sha256: 238d2c7b622b4e15d39b6bd38f9d5f7427cdc875825f48f4e0e87f8b382de464

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 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

3 entries across 3 versions & 1 rubygems

Version Path
rails_best_practices-1.1.0 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-1.0.1 lib/rails_best_practices/core/model_associations.rb
rails_best_practices-1.0.0 lib/rails_best_practices/core/model_associations.rb