Sha256: 8b5fae099e11e4c84e3570d706289ff8a72f382543a057b1f6c0cca9fcd9a958
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
module Dorsale::CustomerVault::Person extend ActiveSupport::Concern def self.t(*args) ::Dorsale::CustomerVault::Corporation.t(*args) end included do acts_as_taggable has_many :comments, -> { order("id DESC") }, class_name: ::Dorsale::Comment, as: :commentable, dependent: :destroy has_one :address, class_name: ::Dorsale::Address, as: :addressable, inverse_of: :addressable, dependent: :destroy has_many :tasks, class_name: ::Dorsale::Flyboy::Task, as: :taskable, dependent: :destroy accepts_nested_attributes_for :address, allow_destroy: true after_destroy :destroy_links def person_type self.class.to_s.split("::").last.downcase.to_sym end def tags_on(*args) super(*args).order(:name) end def links a = ::Dorsale::CustomerVault::Link.where(alice_id: self.id, alice_type: self.class.to_s).map {|l| {title: l.title, person: l.bob, origin: l}} b = ::Dorsale::CustomerVault::Link.where(bob_id: self.id, bob_type: self.class.to_s).map {|l| {title: l.title, person: l.alice, origin: l}} return a + b end def destroy_links links.map{ |l| l[:origin].destroy! } end end end
Version data entries
4 entries across 4 versions & 1 rubygems