class MaterialRelease < ApplicationRecord
  include Confirmable
  include Contractable
  include Exploitable
  include Notable
  include Photoable
  include Releasable
  include Searchable
  include Signable
  include Syncable
  include Taggable
  include PersonName
  
  composed_of :person_address, 
              class_name: "Address",
              mapping: [
                %w(person_address_street1 street1),
                %w(person_address_street2 street2),
                %w(person_address_city city),
                %w(person_address_state state),
                %w(person_address_zip zip),
                %w(person_address_country country)
              ]

  validates :name, presence: true
  validates :person_email, email: true, allow_blank: true

  with_options on: :native do
    validates :person_first_name, :person_last_name, presence: true
    validates :signature, attached: true
  end

  searchable_on %i[ 
    name 
    person_address_street1 person_address_street2 person_address_city person_address_state person_address_zip person_address_country
  ]

  def contact_person
    @contact_person ||= Contact.new(person_name, person_address, person_email, person_phone)
  end
  
  def minor?
    false
  end

  def uses_edl?
    true
  end
end
