Sha256: 19df07987e0db56c154450a9dded3569d4473663c8d0b40e08056b3e51efdfb3

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

module DataWorks
  class Relationships

    def self.autocreated_children=(hash)
      @autocreated_children = hash
    end

    def self.autocreated_children_of(model_name)
      @autocreated_children[model_name] || []
    end

    def self.necessary_parents=(hash)
      @necessary_parents = hash
      StaleRelationshipChecker.check!
    end

    def self.necessary_parents_for(model_name)
      result = @necessary_parents[model_name]
      if result.nil?
        message = "The model '#{model_name}' is not registered. "
        message << "It should be registered in the DataWorks.configure section "
        message << "of your spec_helper.rb file."
        raise DataWorksError.new(message)
      end
      result.map{|x| NecessaryParent.new(x)}
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_works-0.1.1 lib/data_works/relationships.rb