Sha256: a8584f8892ef07da4fa67206d47b02b04ddcde62422cb79895abbbcd4b87d21e
Contents?: true
Size: 996 Bytes
Versions: 1
Compression:
Stored size: 996 Bytes
Contents
module Dread class MissingGraph attr_reader :clazz def initialize(clazz) @clazz = clazz.classify.constantize end def missing_dependables possesionable_associations.map do |assoc_name, assoc_data| assoc_name if direct_association_with_no_dependents?(assoc_data) end.compact end private def direct_association_with_no_dependents?(assoc_data) assoc_data.options[:through].nil? && assoc_data.options[:dependent].nil? end def possesionable_associations has_many_associations.merge(has_one_associations) end def has_many_associations @has_many_associations ||= begin clazz.reflections.select do |assoc_name, assoc_data| assoc_data.macro == :has_many end end end def has_one_associations @has_one_associations ||= begin clazz.reflections.select do |assoc_name, assoc_data| assoc_data.macro == :has_one end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dread-0.1.0 | lib/dread/missing_graph.rb |