forest_liana 1.3.53 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 899aa3a66e7c51f41023be6983ede2661af81c59
4
- data.tar.gz: 4072f4e128d932b43493b40709f893b446fdd31b
3
+ metadata.gz: 1a7229704c77f8cfd736612e9d87923d76da4055
4
+ data.tar.gz: 5299b2f3ccc11bc872bc958a89b461cca222bc97
5
5
  SHA512:
6
- metadata.gz: a5e48b7e1778d1cb6ea43e18bd2d18fb225c6fd908528612e2caaca4fc7001a7acef2c24986ebfd78d67b66c9503cecbb726a2fd2a6ebab356635206c05b63f4
7
- data.tar.gz: deec3d583749fa1c948d6597fe418100e78aff76f9a0098c123e8e20dba60d60bed8bbd2b0209ad23b92aa5368f18242e45c792b971d15e97924e3d6deae4aa8
6
+ metadata.gz: 608232dda20bd3a5adc8efe2ac3a33405277169b47bc70783292be0366478b9186f8d59567e3117c5f71ee45db111ba29e76752bee4ce4c436e55aac8763e853
7
+ data.tar.gz: 1b014e096a8cef6d2273261f465e264693bf90af3d502c2927e6c835514e8c5da2d07028fc2d16260273c5fd4c0e81378de94127b638f98f2225b78a9109fcda
@@ -154,6 +154,19 @@ module ForestLiana
154
154
  serializer.attribute(attr)
155
155
  end
156
156
 
157
+ # NOTICE: Format properly the time type fields during the serialization.
158
+ attributes_time(active_record_class).each do |attr|
159
+ serializer.attribute(attr) do |x|
160
+ value = object.send(attr)
161
+ if value
162
+ match = /(\d{2}:\d{2}:\d{2})/.match(value.to_s)
163
+ (match && match[1]) ? match[1] : nil
164
+ else
165
+ nil
166
+ end
167
+ end
168
+ end
169
+
157
170
  # CarrierWave url attribute
158
171
  if active_record_class.respond_to?(:mount_uploader)
159
172
  active_record_class.uploaders.each do |key, value|
@@ -263,6 +276,12 @@ module ForestLiana
263
276
  end
264
277
  end
265
278
 
279
+ def attributes_time(active_record_class)
280
+ active_record_class.column_names.select do |column_name|
281
+ active_record_class.column_types[column_name].type == :time
282
+ end
283
+ end
284
+
266
285
  def association?(active_record_class, column_name)
267
286
  foreign_keys(active_record_class).include?(column_name)
268
287
  end
@@ -31,9 +31,9 @@ module ForestLiana
31
31
  @association.klass
32
32
  .reflect_on_all_associations
33
33
  .select do |association|
34
- inclusion = SchemaUtils.model_included?(association.klass) &&
35
- [:belongs_to, :has_and_belongs_to_many].include?(association.macro) &&
36
- !association.options[:polymorphic]
34
+ inclusion = !association.options[:polymorphic] &&
35
+ SchemaUtils.model_included?(association.klass) &&
36
+ [:belongs_to, :has_and_belongs_to_many].include?(association.macro)
37
37
 
38
38
  if @field_names_requested
39
39
  inclusion && @field_names_requested.include?(association.name)
@@ -232,26 +232,16 @@ module ForestLiana
232
232
  end
233
233
 
234
234
  case column.type
235
- when :integer
236
- type = 'Number'
237
- when :float
238
- type = 'Number'
239
- when :decimal
240
- type = 'Number'
241
- when :datetime
242
- type = 'Date'
243
- when :date
244
- type = 'Date'
245
- when :string
246
- type = 'String'
247
- when :text
248
- type = 'String'
249
- when :citext
250
- type = 'String'
251
- when :uuid
252
- type = 'String'
253
235
  when :boolean
254
236
  type = 'Boolean'
237
+ when :datetime, :date
238
+ type = 'Date'
239
+ when :integer, :float, :decimal
240
+ type = 'Number'
241
+ when :string, :text, :citext, :uuid
242
+ type = 'String'
243
+ when :time
244
+ type = 'Time'
255
245
  end
256
246
 
257
247
  is_array = (column.respond_to?(:array) && column.array == true)
@@ -151,7 +151,7 @@ More info at: https://github.com/ForestAdmin/forest-rails/releases/tag/1.2.0"
151
151
  def require_lib_forest_liana
152
152
  path = Rails.root.join('lib', 'forest_liana', '**', '*.rb')
153
153
  Dir.glob(File.expand_path(path, __FILE__)).each do |file|
154
- require file
154
+ load file
155
155
  end
156
156
  end
157
157
 
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.3.53"
2
+ VERSION = "1.4.0"
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.3.53
4
+ version: 1.4.0
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-05 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails