Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AuditReporter
- include ActionView::Helpers::UrlHelper
- def initialize(audit, template)
- @audit = audit
- @auditable = audit.auditable
- @template = template
- end
- def report
- method = "#{@audit.kind}_#{@audit.auditable_type.downcase}"
- send(method)
- end
- def method_missing(*args, &block)
- "A #{@audit.kind} event occurred on #{@audit.auditable_type} #{@audit.auditable_id}."
- end
- private
- def create_profile
- "A new profile, #{profile_link(@auditable)}, was added."
- end
- def create_artifacttemplate
- "A new template, #{template_link(@auditable)}, was added to profile, #{profile_link(@auditable.profile)}."
- end
- def create_artifact
- "A new artifact, #{artifact_link(@auditable)}, was added to template, #{profile_link(@auditable.artifact_template)}."
- end
- def create_artifactversion
- "A new version (##{@auditable.my_version}) was discovered for artifact, #{artifact_link(@auditable.artifact)}."
- end
- def profile_link(profile)
- url = @template.send(:profile_url, profile)
- link_to profile.name, url
- end
- def template_link(template)
- url = @template.send(:profile_template_url, template.profile, template)
- link_to template.name, url
- end
- def artifact_link(artifact)
- url = @template.send(:profile_template_artifact_url, artifact.artifact_template.profile, artifact.artifact_template, artifact)
- link_to artifact.name, url
- end
- end
Add Comment
Please, Sign In to add comment