lib/audited/s3_auditor_proxy.rb
def retrieve_audits_from_s3
    [].tap do |results|
      auditable_audit = new_audit({})
      auditable_s3_key = @s3_auditor.resolve_s3_key(auditable_audit)
      results.concat(@s3_auditor.read_audits(auditable_s3_key, auditable_audit.auditable))

      unless @auditor.audit_associated_with.nil?
        associated_audit_attrs = { associated: @auditor.send(@auditor.audit_associated_with) }
        associated_audit = new_audit(associated_audit_attrs)
        associated_s3_key = @s3_auditor.resolve_s3_key(associated_audit)
        results.concat(@s3_auditor.read_audits(associated_s3_key, associated_audit.auditable))
      end
    end
  end
# Audits can exist in two locations. For example, let's say an employee can
# be associated with a company but doesn't have to be. On creation, the employee
# doesn't belong to a company, but later on the employee gets assigned to it.
# In such a case, we'd have two audit files we need to read from:
# 1. auditable_type_audits/employee/1.audits
# 2. associated_type_audits/company/1.audits
Audits can exist in two locations. For example, let's say an employee can
be associated with a company but doesn't have to be. On creation, the employee
doesn't belong to a company, but later on the employee gets assigned to it.
In such a case, we'd have two audit files we need to read from:
1.
Audits can exist in two locations . For example let ' s say an employee can be associated with a company but doesn ' t have to be . On creation the employee doesn ' t belong to a company but later on the employee gets assigned to it . In such a case we ' d have two audit files we need to read from : 1 .
def retrieve_audits_from_s3
    [].tap do |results|
      auditable_audit = new_audit({})
      auditable_s3_key = @s3_auditor.resolve_s3_key(auditable_audit)
      results.concat(@s3_auditor.read_audits(auditable_s3_key, auditable_audit.auditable))
      unless @auditor.audit_associated_with.nil?
        associated_audit_attrs = { associated: @auditor.send(@auditor.audit_associated_with) }
        associated_audit = new_audit(associated_audit_attrs)
        associated_s3_key = @s3_auditor.resolve_s3_key(associated_audit)
        results.concat(@s3_auditor.read_audits(associated_s3_key, associated_audit.auditable))
      end
    end
  end
def retrieve_audits_from_s3 [ ] . tap do | results | auditable_audit = new_audit ( { } ) auditable_s3_key = @s3_auditor . resolve_s3_key ( auditable_audit ) results . concat ( @s3_auditor . read_audits ( auditable_s3_key , auditable_audit . auditable ) ) unless @auditor . audit_associated_with . nil? associated_audit_attrs = { associated : @auditor . send ( @auditor . audit_associated_with ) } associated_audit = new_audit ( associated_audit_attrs ) associated_s3_key = @s3_auditor . resolve_s3_key ( associated_audit ) results . concat ( @s3_auditor . read_audits ( associated_s3_key , associated_audit . auditable ) ) end end end
Audits can exist in two locations.
Audits can exist in two locations .