Class: PolicyManager::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/policy_manager/exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.attachment_path = opts[:attachment_path]
  self.attachment_storage = 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_zipObject

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_pathObject

Returns the value of attribute attachment_path.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def attachment_path
  @attachment_path
end

#attachment_storageObject

Returns the value of attribute attachment_storage.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def attachment_storage
  @attachment_storage
end

Returns the value of attribute customize_link.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def customize_link
  @customize_link
end

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_templateObject

Returns the value of attribute index_template.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def index_template
  @index_template
end

#layoutObject

Returns the value of attribute layout.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def layout
  @layout
end

#mail_helpersObject

Returns the value of attribute mail_helpers.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def mail_helpers
  @mail_helpers
end

#mailerObject

Returns the value of attribute mailer.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def mailer
  @mailer
end

#mailer_templatesObject

Returns the value of attribute mailer_templates.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def mailer_templates
  @mailer_templates
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/policy_manager/exporter.rb', line 5

def path
  @path
end

#resourceObject

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_templateObject



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