lp_csv_exportable 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3805b8cffef76f6642c1a073d98efa651b1a3d07
4
- data.tar.gz: 07b0b866d5857e622d31045f180e06a97077dd9b
3
+ metadata.gz: 27cb7b83786f789431b64a9bbf8873e3123bedcf
4
+ data.tar.gz: 13706fb398738f69d914c5161a526c9973feb1d7
5
5
  SHA512:
6
- metadata.gz: 592194d4195a038db32d718b997dde273ff62a171237abc1f73a24cb2db60dba14105877ef574a87f3735e0f6860bb42c40f4751353a5effa833c343e8c3c921
7
- data.tar.gz: a6370821f0dffab8b52cb9f3276e1b3acc62efa455ca55a0cd1f1ba6c9490b56a132259ad47ef128916466f057c1a2a8423be498acb163ceee0acce8a40b9a09
6
+ metadata.gz: 4d9d48093288b6d91c293bce15cfc4aad9dc13085be75e2acdb4e6d86fa1ea607a7671bdd7007462fc9bcacdc73421dace781813edbdd6d63f9af031f2df3739
7
+ data.tar.gz: fc3919e22f6ef0d83a7b57f339880e544f0a6ab0e59d5be21b17868f1f6c9445fd08d8394d46f2605181dd2700e4d6ad25cfac698c34e8181d0fae8248e2a594
data/README.md CHANGED
@@ -41,7 +41,8 @@ And then to export, simply instantiate your class and pass in your `collection`,
41
41
 
42
42
  respond_to do |format|
43
43
  format.csv do
44
- export = ExportUsers.new(collection: attendees)
44
+ export = ExportUsers.new
45
+ export.collection = users
45
46
  send_data export.to_csv
46
47
  end
47
48
  end
@@ -1,16 +1,11 @@
1
1
  module LpCSVExportable
2
2
  module CanExportAsCSV
3
- attr_reader :collection
3
+ attr_accessor :collection
4
4
 
5
5
  def self.included(base)
6
6
  base.extend ClassMethods
7
7
  end
8
8
 
9
- def initialize(args = {})
10
- @collection = args[:collection]
11
- after_init(args)
12
- end
13
-
14
9
  def to_csv
15
10
  CSV.generate do |csv|
16
11
  csv << headers
@@ -22,10 +17,6 @@ module LpCSVExportable
22
17
 
23
18
  private
24
19
 
25
- def after_init(args = {})
26
- # hook
27
- end
28
-
29
20
  def columns
30
21
  self.class.columns_hashes.map do |hash|
31
22
  CSVColumn.new(hash)
@@ -64,6 +55,12 @@ module LpCSVExportable
64
55
  end
65
56
  end
66
57
 
58
+ def collection
59
+ raise 'collection has not been set on the class' unless @collection
60
+ raise 'collection must respond to map method' unless @collection.respond_to?(:map)
61
+ @collection
62
+ end
63
+
67
64
  # Configuration...
68
65
  module ClassMethods
69
66
  def column(header, options = {})
@@ -1,3 +1,3 @@
1
1
  module LpCSVExportable
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lp_csv_exportable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Francis