azahara_schema 0.2.5 → 0.2.6

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
  SHA256:
3
- metadata.gz: 1777d746f39956e29cd1cd32964e1490fb245d163d969b8affeebdcd8442c701
4
- data.tar.gz: c1917a9d9db187ad562d90b598124dd1ad2d77f1292e588c6b44ab7d05b2631c
3
+ metadata.gz: ded2c6d31f576f6352ac1a71aa199652a02291d012c6ff46a0dee6cdba9ecebd
4
+ data.tar.gz: 230a4c8a4c4167edad95506997195b173eedbd81f45e3194058e6930493ee682
5
5
  SHA512:
6
- metadata.gz: ddbdfa153298fe7f3afd19c214a23a841b4207dc2399590cbd1623b6ec289e89ee141ef6e2e7a649a33cfbe4d4d5dff3b2a72489f0fada1e01067a6165957c60
7
- data.tar.gz: 733a0ac3ddfce522ee22d6a1a49673d5ebc752dcbadc2c1862f9921238a6ef8b9b75c1babb4956fdec7c903d1634f68b4bd0b528e7708f279590d10710453e83
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, residence: o.person.residence.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
@@ -1,3 +1,3 @@
1
1
  module AzaharaSchema
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
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.5
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-07 00:00:00.000000000 Z
11
+ date: 2018-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails