Sha256: dcd1f0fba0c865b5bcd7256879e8a166e6668fcc3b3bdb441ec807ce43cfbdec

Contents?: true

Size: 1.75 KB

Versions: 5

Compression:

Stored size: 1.75 KB

Contents

module Concernz
  module Claim
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'claim_id'

      # maybe Claim concerns Incident and maybe Incident was independently witnessed by Witness and Witness is a kind of Person
      belongs_to :person_via_incident_witness, :class_name => 'Person', :foreign_key => :incident_witness_id

      # Claim concerns Incident and Incident is a Vehicle Incident
      has_one :vehicle_incident_via_incident, :class_name => 'VehicleIncident', :foreign_key => :incident_claim_id, :dependent => :destroy
    end
  end
end

module Concernz
  module Person
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'person_id'

      # Person is a Witness and maybe Witness saw Incident and maybe Incident resulted in Claim
      has_many :claims_via_incident_witness, :class_name => 'Claim', :foreign_key => :incident_witness_id, :dependent => :destroy

      # Person is a Driver and maybe Vehicle Incident occurred while Driver was in charge
      has_many :vehicle_incidents_via_driver, :class_name => 'VehicleIncident', :foreign_key => :driver_id, :dependent => :destroy

      validates :person_name, :presence => true
    end
  end
end

module Concernz
  module VehicleIncident
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'incident_claim_id'

      # Vehicle Incident is a kind of Incident and Incident resulted in Claim
      belongs_to :claim_via_incident, :class_name => 'Claim', :foreign_key => :incident_claim_id

      # maybe Vehicle Incident occurred while Driver was in charge and Driver is a kind of Person
      belongs_to :person_via_driver, :class_name => 'Person', :foreign_key => :driver_id

      validates :incident_claim_id, :presence => true
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activefacts-examples-1.9.9 rails/models/SeparateSubtype.models
activefacts-examples-1.9.8 rails/models/SeparateSubtype.models
activefacts-examples-1.8.0 rails/models/SeparateSubtype.models
activefacts-examples-1.7.2 rails/models/SeparateSubtype.models
activefacts-examples-1.7.1 rails/models/SeparateSubtype.models