app/models/unidom/party/party_relation.rb in unidom-party-0.7 vs app/models/unidom/party/party_relation.rb in unidom-party-1.0

- old
+ new

@@ -13,23 +13,12 @@ belongs_to :target_party, polymorphic: true scope :source_party_is, ->(source_party) { where source_party: source_party } scope :target_party_is, ->(target_party) { where target_party: target_party } - def self.relate(source_party, target_party, linkage_code: 'FRND', grade: 0, opened_at: Time.now, priority: 0, attributes: {}) + def self.relate!(source_party: nil, target_party: nil, linkage_code: 'FRND', grade: 0, opened_at: Time.now, priority: 0, attributes: {}) relation = source_party_is(source_party).target_party_is(target_party).linkage_coded_as(linkage_code).first_or_initialize grade: grade, priority: priority, opened_at: opened_at relation.assign_attributes attributes relation.save! - relation - end - - def self.relate!(source_party, target_party, linkage_code: 'FRND', grade: 0, opened_at: Time.now, priority: 0, attributes: {}) - relation = source_party_is(source_party).target_party_is(target_party).linkage_coded_as(linkage_code).first_or_initialize grade: grade, priority: priority, opened_at: opened_at - relation.assign_attributes attributes - relation.save! - end - - class << self - deprecate relate: :relate!, deprecator: ActiveSupport::Deprecation.new('1.0', 'unidom-party') end end