Class: PolicyManager::Exporter
- Inherits:
-
Object
- Object
- PolicyManager::Exporter
- Defined in:
- lib/policy_manager/exporter.rb
Instance Attribute Summary collapse
-
#after_zip ⇒ Object
Returns the value of attribute after_zip.
-
#attachment_path ⇒ Object
Returns the value of attribute attachment_path.
-
#attachment_storage ⇒ Object
Returns the value of attribute attachment_storage.
-
#customize_link(url) ⇒ Object
Returns the value of attribute customize_link.
-
#expiration_link ⇒ Object
Returns the value of attribute expiration_link.
-
#index_template ⇒ Object
Returns the value of attribute index_template.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#mail_helpers ⇒ Object
Returns the value of attribute mail_helpers.
-
#mailer ⇒ Object
Returns the value of attribute mailer.
-
#mailer_templates ⇒ Object
Returns the value of attribute mailer_templates.
-
#path ⇒ Object
Returns the value of attribute path.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #clear!(resource) ⇒ Object
- #default_index_template ⇒ Object
- #handled_template(template) ⇒ Object
-
#initialize(opts = {}) ⇒ Exporter
constructor
A new instance of Exporter.
- #perform(resource) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Exporter
Returns a new instance of Exporter.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/policy_manager/exporter.rb', line 18 def initialize(opts={}) self.path = opts[:path] self.resource = opts[:resource] #.call if opts[:resource].is_a?(Proc) self.index_template = opts[:index_template] self.layout = opts[:layout] self.after_zip = opts[:after_zip] self.mail_helpers = opts[:mail_helpers] self. = opts[:attachment_path] self. = opts[:attachment_storage] self.expiration_link = opts[:expiration_link] self.customize_link = opts[:customize_link] self.mailer_templates = opts[:mailer_templates] end |
Instance Attribute Details
#after_zip ⇒ Object
Returns the value of attribute after_zip.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def after_zip @after_zip end |
#attachment_path ⇒ Object
Returns the value of attribute attachment_path.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def @attachment_path end |
#attachment_storage ⇒ Object
Returns the value of attribute attachment_storage.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def @attachment_storage end |
#customize_link(url) ⇒ Object
Returns the value of attribute customize_link.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def customize_link @customize_link end |
#expiration_link ⇒ Object
Returns the value of attribute expiration_link.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def expiration_link @expiration_link end |
#index_template ⇒ Object
Returns the value of attribute index_template.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def index_template @index_template end |
#layout ⇒ Object
Returns the value of attribute layout.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def layout @layout end |
#mail_helpers ⇒ Object
Returns the value of attribute mail_helpers.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def mail_helpers @mail_helpers end |
#mailer ⇒ Object
Returns the value of attribute mailer.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def mailer @mailer end |
#mailer_templates ⇒ Object
Returns the value of attribute mailer_templates.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def mailer_templates @mailer_templates end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def path @path end |
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'lib/policy_manager/exporter.rb', line 5 def resource @resource end |
Instance Method Details
#clear!(resource) ⇒ Object
37 38 39 40 |
# File 'lib/policy_manager/exporter.rb', line 37 def clear!(resource) e = ExporterHandler.new(resource: resource, path: path) e.clear! end |
#default_index_template ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/policy_manager/exporter.rb', line 71 def default_index_template '<h1>links</h1> <ul> <% @collection.each do |rule| %> <li><%= link_to rule.name, "./#{rule.name}" %></li> <% end %> </ul>' end |
#handled_template(template) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/policy_manager/exporter.rb', line 62 def handled_template(template) return if template.blank? if template.is_a?(String) template elsif template.is_a?(Pathname) File.open(template).read end end |
#perform(resource) ⇒ Object
32 33 34 35 |
# File 'lib/policy_manager/exporter.rb', line 32 def perform(resource) e = ExporterHandler.new(resource: resource, path: path, after_zip: after_zip) e.perform end |