Class: DataWorks::Relationships

Inherits:
Object
  • Object
show all
Defined in:
lib/data_works/relationships.rb

Class Method Summary collapse

Class Method Details

.autocreated_children=(hash) ⇒ Object



4
5
6
# File 'lib/data_works/relationships.rb', line 4

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

.autocreated_children_of(model_name) ⇒ Object



8
9
10
# File 'lib/data_works/relationships.rb', line 8

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

.necessary_parents=(hash) ⇒ Object



12
13
14
15
# File 'lib/data_works/relationships.rb', line 12

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

.necessary_parents_for(model_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/data_works/relationships.rb', line 17

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