lib/data_miner/attribute.rb in seamusabshere-data_miner-0.2.0 vs lib/data_miner/attribute.rb in seamusabshere-data_miner-0.2.1
- old
+ new
@@ -7,10 +7,26 @@
@name = name.to_sym
@options_for_step = {}
@affected_by_steps = []
@key_for_steps = []
end
+
+ # polling questions
+ def report_find_or_create(step)
+ "Creates parents: #{klass}##{name} is set with #{reflection_klass(step)}.find_or_create_by_#{foreign_key(step)}" if wants_create?(step)
+ end
+
+ def report_unnatural_order(step)
+ if (
+ (rk = klass.reflect_on_association(weighting_association(step)).andand.klass) or
+ (wants_inline_association? and rk = reflection_klass(step))
+ ) and
+ step.configuration.classes.index(rk) > step.configuration.classes.index(klass) and
+ step.options[:awaiting].andand.klass != klass
+ "Unnatural order: #{klass} comes before #{rk}"
+ end
+ end
def inspect
"Attribute(#{klass}.#{name})"
end
@@ -242,10 +258,10 @@
end
def reflection_klass(step)
return nil unless reflection
if reflection.options[:polymorphic]
- polymorphic_type(step).constantize
+ polymorphic_type(step).andand.constantize
else
reflection.klass
end
end