forest_liana 1.4.5 → 1.4.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: 3abc2cedf799ed432538f68b9710ed9f48a20b69
4
- data.tar.gz: 6e7adcf88252854a67c0c6d3d44f50b510435d17
3
+ metadata.gz: 6dac4da1a71a663bfdd2f36870f8e5ccbc150b03
4
+ data.tar.gz: ffc0af068f5056eaa86920ca86dcdc3097509d85
5
5
  SHA512:
6
- metadata.gz: 8435daf472d626aacca2c6b7cdafb213fe8018993a15b306e21ec84d0a40211f90cae59dcdf87b78d5efc16885d9899c78c22dfacdae16e47ae9aea99482b30c
7
- data.tar.gz: af9bf03170b9c886a26bb193057710ac7af2f981d56dec2f6766a56d26d050e9890a41334257b035ea888bbdec8c0eb95ecf957826be4be8760e858580d56363
6
+ metadata.gz: 06f4028b47406055fec5ff180cc966fafdef44b8b3dfbc1e756cf85a716647852e85db519480582d20d919ca98029d607b67de7acd2bfa7bbb9866bb565e9cb5
7
+ data.tar.gz: ea027353665909b1c751896a84ccd0e96db8e0b97c4d5cf35a21c5f9bfe775adc3deb0c879a0e8d909e9912e32543acbe523c25d01a58d19ff271a740a0401c0
@@ -30,7 +30,7 @@ module ForestLiana
30
30
  end
31
31
 
32
32
  def extract_attributes_serialize
33
- @resource.serialized_attributes.each do |attribute, serializer|
33
+ attributes_serialized.each do |attribute, serializer|
34
34
  value = @params[:data][:attributes][attribute]
35
35
  @attributes[attribute] = JSON::parse(value)
36
36
  end
@@ -123,6 +123,17 @@ module ForestLiana
123
123
  @resource.columns.find { |column| column.name == attribute }.present?
124
124
  end
125
125
 
126
+ def attributes_serialized
127
+ if Rails::VERSION::MAJOR >= 5
128
+ @attributes.select do |attribute|
129
+ @resource.type_for_attribute(attribute).class ==
130
+ ::ActiveRecord::Type::Serialized
131
+ end
132
+ else
133
+ @resource.serialized_attributes
134
+ end
135
+ end
136
+
126
137
  def carrierwave_attribute?(attr)
127
138
  @resource.uploaders.include?(attr.try(:to_sym))
128
139
  end
@@ -168,7 +168,7 @@ module ForestLiana
168
168
  end
169
169
 
170
170
  # NOTICE: Format serialized fields.
171
- active_record_class.serialized_attributes.each do |attribute, serialization|
171
+ attributes_serialized(active_record_class).each do |attribute, serialization|
172
172
  serializer.attribute(attribute) do |x|
173
173
  value = object.send(attribute)
174
174
  value ? value.to_json : nil
@@ -299,6 +299,17 @@ module ForestLiana
299
299
  end
300
300
  end
301
301
 
302
+ def attributes_serialized(active_record_class)
303
+ if Rails::VERSION::MAJOR >= 5
304
+ attributes(active_record_class).select do |attribute|
305
+ active_record_class.type_for_attribute(attribute).class ==
306
+ ::ActiveRecord::Type::Serialized
307
+ end
308
+ else
309
+ active_record_class.serialized_attributes
310
+ end
311
+ end
312
+
302
313
  def association?(active_record_class, column_name)
303
314
  foreign_keys(active_record_class).include?(column_name)
304
315
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.4.5"
2
+ VERSION = "1.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails