deep_pluck 0.0.2 → 0.0.3

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: 349c7b04d2d9ccae350dca8881d3ef4ea0df5c3d
4
- data.tar.gz: ec237b551c395325b18cfd6e7c9e6e661568644a
3
+ metadata.gz: 44d38789b1249442a2a97cf7206309ce2a5125e3
4
+ data.tar.gz: 5e07435ba363c3fbe2a325dc8cd1fec1791228b8
5
5
  SHA512:
6
- metadata.gz: 931c73f32ea5d5ab45968ccacbfa711c0c16fb2a96f3e7fe4fa872faae240741fa906f7927a51c5fcf1d7cd702dc53287b69f70051ec9df297411d109825b2a5
7
- data.tar.gz: 32fb59b2124621239f9b469b07e93b1defbd866c672cc391430ea31634997f95f1e30a11f0a28594797155c65de03d2d4fcf5d3cdd04bf80107c8cc4bd0ec296
6
+ metadata.gz: 44b321b33fdadcefd60a4d1b2319c8b03cb57cd2331888921f7082b830bc664a1d3d66e9533b0f0f12b70a7991b3da888aedb11e68e7532463604a7f5a6c66bc
7
+ data.tar.gz: c28edcfd210948743d1e883f44d2e40f73db88ae92f05d8efd48e423006566e6c5903f3f255688e609438852a6306bec8725b13d968d636165a23aa8d827e128
@@ -14,12 +14,12 @@ module DeepPluck
14
14
  # Reader
15
15
  #---------------------------------------
16
16
  def reflect_on_association(association_key)
17
- @relation.klass.reflect_on_association(association_key)
17
+ @relation.klass.reflect_on_association(association_key.to_sym) #add to_sym since rails 3 only support symbol
18
18
  end
19
19
  def get_foreign_key(association_key, reverse = false)
20
20
  reflect = reflect_on_association(association_key)
21
- return (reflect.belongs_to? ? 'id' : reflect.foreign_key) if reverse
22
- return (reflect.belongs_to? ? reflect.foreign_key : 'id')
21
+ return (reflect.belongs_to? ? @relation.klass.primary_key : reflect.foreign_key) if reverse
22
+ return (reflect.belongs_to? ? reflect.foreign_key : @relation.klass.primary_key)
23
23
  end
24
24
  #---------------------------------------
25
25
  # Contruction OPs
@@ -81,15 +81,16 @@ module DeepPluck
81
81
  all_need_columns = [*prev_need_columns, *next_need_columns, *@need_columns].uniq
82
82
  @extra_columns = all_need_columns - @need_columns
83
83
  @relation = yield(@relation) if block_given?
84
- return (@data = @relation.pluck_all(*all_need_columns))
85
- end
86
- def load_all
87
- data = load_data
84
+ @data = @relation.pluck_all(*all_need_columns)
88
85
  @associations.each do |key, model|
89
- set_includes_data(data, key, model)
86
+ set_includes_data(@data, key, model)
90
87
  end
88
+ return @data
89
+ end
90
+ def load_all
91
+ load_data
91
92
  delete_extra_column_data!
92
- return data
93
+ return @data
93
94
  end
94
95
  def delete_extra_column_data!
95
96
  @data.each{|s| s.except!(*@extra_columns) } if @data
@@ -1,3 +1,3 @@
1
1
  module DeepPluck
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_pluck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy