pluckeroid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/pluckeroid/active_record/relation.rb +6 -6
- data/lib/pluckeroid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzNmZjlmNTJlZTI0MTYyY2JjZWFmNTdhYzRjNmFjN2M4NWJhZTY3ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTY3Njc1MjE5MWIwNmM5OWYxODcxN2JhYzJiYmZlMDI5ZjY0MjUzMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGVkNGE4MWZiZWVmZWQ1NzNjOThiNzIzNGE0N2M0NDlhMTc5Y2FhMmM2Njg4
|
10
|
+
MjQ2ZWQ5NzVhNzI3MTYxNTQxNWVjYjQyZWUxZjgzZTNjOWU2ZTFjZWQwOWRl
|
11
|
+
ODhjMDhlMzM0NTkzN2RjOTVhOTMxYmQ2NTBiODA4YzhlNjZkMDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTBhZTcyZTljNzRmZmExNDFmMTBkNWViODFiNzhmZjU1MGIwZjQ1NDJmOTNh
|
14
|
+
NTIxZDA4OGRmNGMwMDIxNGE0ZDA2NjRhNDYwOWFhZjk1NDI4ZGRiZDA3N2Jk
|
15
|
+
NzllYjc1MjhiYzBjMjVkYWU5MTI0YmM3ZTM2MDE0NzA2MWYzZjc=
|
@@ -29,10 +29,10 @@ module Pluckeroid
|
|
29
29
|
# Examples:
|
30
30
|
#
|
31
31
|
# Person.pluck(:id) # SELECT people.id FROM people
|
32
|
-
# => [1, 2]
|
32
|
+
# # => [1, 2]
|
33
33
|
#
|
34
34
|
# Person.pluck(:id, :name) # SELECT people.id, people.name FROM people
|
35
|
-
# => [[1, 'Obi-Wan'], [2, 'Luke']]
|
35
|
+
# # => [[1, 'Obi-Wan'], [2, 'Luke']]
|
36
36
|
#
|
37
37
|
def pluck(*column_names)
|
38
38
|
flatten = column_names.size == 1
|
@@ -54,12 +54,12 @@ module Pluckeroid
|
|
54
54
|
|
55
55
|
protected
|
56
56
|
|
57
|
-
def pluck_columns(
|
58
|
-
if
|
57
|
+
def pluck_columns(columns)
|
58
|
+
if columns.size.zero?
|
59
59
|
raise ArgumentError, 'wrong number of arguments (0 for 1)'
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
columns = columns.map do |column_name|
|
63
63
|
if Symbol === column_name && column_names.include?(column_name.to_s)
|
64
64
|
"#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}"
|
65
65
|
else
|
@@ -68,7 +68,7 @@ module Pluckeroid
|
|
68
68
|
end
|
69
69
|
|
70
70
|
relation = clone
|
71
|
-
relation.select_values =
|
71
|
+
relation.select_values = columns
|
72
72
|
klass.connection.select_all(relation.arel).map! do |attributes|
|
73
73
|
yield klass.initialize_attributes(attributes)
|
74
74
|
end
|
data/lib/pluckeroid/version.rb
CHANGED