azahara_schema 0.2.5 → 0.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded2c6d31f576f6352ac1a71aa199652a02291d012c6ff46a0dee6cdba9ecebd
|
4
|
+
data.tar.gz: 230a4c8a4c4167edad95506997195b173eedbd81f45e3194058e6930493ee682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a672e53ee815b9b9f4d5ce4212153175d7c2013e45b4945f39ba3c2129d9dcfec7cba1e0d609a6365193143655c60a3e834b2b004ba539d02e770f3582955c92
|
7
|
+
data.tar.gz: 03aba7ed60de1e7ad8437ca25631c4325c0cd476bb8a9aad1a95aa3baa8191ef8103208427f227822956c26f833cb9086a316167beee0b3c2786b7d44abb73d8
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module AzaharaSchema
|
2
2
|
module ControllerAdditions
|
3
3
|
|
4
|
-
def azahara_schema_index(**options)
|
4
|
+
def azahara_schema_index(**options, &block)
|
5
5
|
@resource_schema = self.class.cancan_resource_class.new(self).send(:collection_instance)
|
6
|
-
@resource_schema.from_params(params)
|
6
|
+
@resource_schema.from_params(params.reverse_merge(options[:defaults] || {}))
|
7
|
+
yield(@resource_schema) if block_given?
|
7
8
|
respond_to do |format|
|
8
9
|
format.html
|
9
10
|
format.json {
|
10
11
|
json_result = {}
|
11
12
|
if params['_type'] == 'query'
|
12
13
|
json_result[:results] = @resource_schema.entities.collect do |o|
|
13
|
-
{id: o.id, text: o.to_s
|
14
|
+
{id: o.id, text: o.to_s}
|
14
15
|
end
|
15
16
|
elsif params['_type'] == 'count'
|
16
17
|
json_result = {count: @resource_schema.entity_count}
|
@@ -89,6 +89,17 @@ module AzaharaSchema
|
|
89
89
|
|
90
90
|
class BooleanFormat < Base
|
91
91
|
add 'boolean'
|
92
|
+
|
93
|
+
def sanitize_value(value)
|
94
|
+
case value
|
95
|
+
when '0', 'false', false
|
96
|
+
false
|
97
|
+
when nil
|
98
|
+
nil
|
99
|
+
else
|
100
|
+
!!value
|
101
|
+
end
|
102
|
+
end
|
92
103
|
end
|
93
104
|
|
94
105
|
class StringFormat < Base
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azahara_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|