Sha256: b3f8ac784aeefa186bba2396695e4597d56d77300c15c8b5d7097713b238c675
Contents?: true
Size: 1.33 KB
Versions: 8
Compression:
Stored size: 1.33 KB
Contents
module Abstractor module Methods module Models module AbstractorAbstractionGroup def self.included(base) base.send :include, SoftDelete # Associations base.send :belongs_to, :abstractor_subject_group base.send :belongs_to, :about, polymorphic: true base.send :has_many, :abstractor_abstraction_group_members base.send :has_many, :abstractor_abstractions, :through => :abstractor_abstraction_group_members base.send :attr_accessible, :abstractor_subject_group, :abstractor_subject_group_id, :deleted_at, :about, :about_type, :about_id # Hooks base.send :after_commit, :update_abstractor_abstraction_group_members, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') } end ## # Determines if the group can be removed. # # @return [Boolean] def removable? abstractor_abstractions.map(&:abstractor_suggestions).flatten.empty? end private def update_abstractor_abstraction_group_members return unless deleted? abstractor_abstraction_group_members.each do |gm| gm.soft_delete! gm.abstractor_abstraction.soft_delete! end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems