Module: Para::Exporter
- Defined in:
- lib/para/exporter.rb,
lib/para/exporter/csv.rb,
lib/para/exporter/base.rb
Defined Under Namespace
Classes: Base, Csv, MissingExporterError
Class Method Summary
collapse
Class Method Details
.base_exporters ⇒ Object
50
51
52
|
# File 'lib/para/exporter.rb', line 50
def self.base_exporters
@base_exporters ||= {}.with_indifferent_access
end
|
.for(model_name, format) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/para/exporter.rb', line 20
def self.for(model_name, format)
exporter_name = name_for(model_name, format)
begin
const_get(exporter_name)
rescue NameError => e
if e.message == "uninitialized constant Para::Exporter::#{ exporter_name }"
raise MissingExporterError.new(model_name, format, exporter_name)
else
raise e
end
end
end
|
46
47
48
|
# File 'lib/para/exporter.rb', line 46
def self.format_exporter_name(format)
format.to_s.camelize
end
|
.model_exporter_name(model_name) ⇒ Object
42
43
44
|
# File 'lib/para/exporter.rb', line 42
def self.model_exporter_name(model_name)
[model_name.to_s.pluralize, 'Exporter'].join
end
|
.name_for(model_name, format) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/para/exporter.rb', line 34
def self.name_for(model_name, format)
[
'',
format_exporter_name(format),
model_exporter_name(model_name)
].join('::')
end
|