excelizer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -1
- data/lib/excelizer/version.rb +1 -1
- data/lib/excelizer.rb +11 -5
- metadata +2 -4
- data/README_ES.md +0 -1
- data/Rakefile +0 -1
data/README.md
CHANGED
@@ -36,6 +36,7 @@ It's possible to redefine attributes using the `@model` reference
|
|
36
36
|
def name
|
37
37
|
@model.name.titleize
|
38
38
|
end
|
39
|
+
|
39
40
|
end
|
40
41
|
|
41
42
|
Or even create new attributes. Keep in mind new attributes will be added at the end of the row, but you can explicitly define the position where they should be. In this example, `phone_number` will go before `birth_date` while `favorite_color` will go after it.
|
@@ -96,5 +97,10 @@ Brought to you by Arturo Puente and the team at [Phantasia](http://www.phantasia
|
|
96
97
|
|
97
98
|
## Changelog
|
98
99
|
|
99
|
-
0.0.
|
100
|
+
0.0.9 Adds support for Rails 4.
|
101
|
+
0.0.8 Safer attribute initialization.
|
100
102
|
0.0.7 First release. Codename: Bond
|
103
|
+
|
104
|
+
## License
|
105
|
+
|
106
|
+
This project is released under the [MIT license](http://opensource.org/licenses/MIT).
|
data/lib/excelizer/version.rb
CHANGED
data/lib/excelizer.rb
CHANGED
@@ -26,14 +26,14 @@ module Excelizer
|
|
26
26
|
|
27
27
|
# If the model class has the same method as the one defined in
|
28
28
|
# attr_downloadble, that method will be called.
|
29
|
-
collection.map do |
|
30
|
-
@model =
|
29
|
+
collection.map do |model_instance|
|
30
|
+
@model = model_instance
|
31
31
|
own_methods.map do |attr|
|
32
32
|
# Checks if the model has a method with the same name and
|
33
33
|
# if the class definition overrides the model method
|
34
34
|
reciever = self
|
35
35
|
if model_methods.include?(attr.to_s) && reciever.send(attr).nil?
|
36
|
-
reciever =
|
36
|
+
reciever = model_instance
|
37
37
|
end
|
38
38
|
reciever.send(attr)
|
39
39
|
end.compact
|
@@ -43,9 +43,15 @@ module Excelizer
|
|
43
43
|
def model_class
|
44
44
|
Object.const_get self.class.name.gsub "Downloader", ""
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def model_clean_attributes(model_class_ref)
|
48
|
-
model_class_ref.new.attributes.keys
|
48
|
+
explicit_attribute_keys = model_class_ref.new.attributes.keys
|
49
|
+
|
50
|
+
if model_class_ref.respond_to?(:protected_attributes)
|
51
|
+
explicit_attribute_keys - model_class_ref.protected_attributes.to_a
|
52
|
+
else
|
53
|
+
explicit_attribute_keys
|
54
|
+
end
|
49
55
|
end
|
50
56
|
|
51
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excelizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -71,8 +71,6 @@ files:
|
|
71
71
|
- Gemfile
|
72
72
|
- LICENSE.txt
|
73
73
|
- README.md
|
74
|
-
- README_ES.md
|
75
|
-
- Rakefile
|
76
74
|
- excelizer.gemspec
|
77
75
|
- lib/excelizer.rb
|
78
76
|
- lib/excelizer/version.rb
|
data/README_ES.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Pronto
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|