data_tables 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/data_tables.gemspec +1 -1
- data/lib/data_tables.rb +37 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTg0MjU2ZmY4MjlmY2JjOTQwZDVkYjQ3YTRmNDBmNWM3ZDcwMzUyMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGNkMTc2Mjg2NDNhMTMzYWEwNTc4NDJkNTVlNjNmMTNiZGYyZTU3ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjczMWUzZTc4NDNkZmE2MjRlNjViNWVlMDZjZDBhZmMyNmMwY2Q4YTUxZWFm
|
10
|
+
OTU2OWFmNTAxNGNjOWU2NjJmMmM3YWJjODNjZTc2ZmQ3YmVjODU0Yjc0Nzlj
|
11
|
+
ZWNhNDlhYzAzYTU4NDE5ZWY0MzJmYjYyYmM1MGJjNzZmNDdiNzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MThiNjRlMzg1MGU2Yjg1MjU1ZDllYTM2MGM4OTA5NmVkMmM0OWZkNzIyODg3
|
14
|
+
ZDY5OWE4MmUyMDNjOGMxYjZlZWI5ZGE4NTNiZTA3YzM3N2U0ZjAyNGUzODY5
|
15
|
+
NjM5NWJlZjlhNzUzNGZmZDY5NzhhYTVhMTM0OTRkODk0NDY2Zjc=
|
data/data_tables.gemspec
CHANGED
data/lib/data_tables.rb
CHANGED
@@ -402,24 +402,46 @@ module DataTablesController
|
|
402
402
|
# gets the value for a column and row
|
403
403
|
def datatables_instance_get_value(instance, column)
|
404
404
|
if column[:special]
|
405
|
-
|
406
|
-
|
407
|
-
if special[:method]
|
408
|
-
return method(special[:method].to_sym).call(instance)
|
409
|
-
elsif special[:eval]
|
410
|
-
proc = lambda { obj = instance; binding }
|
411
|
-
return Kernel.eval(special[:eval], proc.call)
|
412
|
-
end
|
405
|
+
get_instance_special_value(instance, column[:special])
|
413
406
|
elsif column[:attribute]
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
else
|
419
|
-
return ''
|
407
|
+
begin
|
408
|
+
get_instance_value(instance.send("#{column[:attribute]}"))
|
409
|
+
rescue ArgumentError => error
|
410
|
+
handle_argument_error(error, instance, column)
|
420
411
|
end
|
412
|
+
else
|
413
|
+
return "value not found"
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
def get_instance_special_value(instance, special)
|
418
|
+
if special[:method]
|
419
|
+
return method(special[:method].to_sym).call(instance)
|
420
|
+
elsif special[:eval]
|
421
|
+
proc = lambda { obj = instance; binding }
|
422
|
+
return Kernel.eval(special[:eval], proc.call)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
def get_instance_value(value)
|
427
|
+
if !value.blank? || value == false
|
428
|
+
trans = I18n.t(value.to_s.to_sym, :default => value.to_s)
|
429
|
+
return trans.class == String ? trans : value.to_s
|
430
|
+
else
|
431
|
+
return ''
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def handle_argument_error(error, instance, column)
|
436
|
+
if error.message.include? "UTF-8"
|
437
|
+
invalid_sequence = instance.send("#{column[:attribute]}").bytes.to_a
|
438
|
+
logger.warn("[datatables] Error: #{instance.class.name} for "+
|
439
|
+
"id #{instance.id}, column #{column[:attribute]}: " +
|
440
|
+
"Invalid UTF8 sequence is [#{invalid_sequence.join(", ")}]")
|
441
|
+
return ''
|
442
|
+
else
|
443
|
+
raise
|
421
444
|
end
|
422
|
-
return "value not found"
|
423
445
|
end
|
424
446
|
|
425
447
|
def datatable_source(name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duane Compton
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|