rails-add_ons 0.4.0 → 0.4.1

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: c9032b619494f0bfa4dc18bfa0c86fe1db0f4071
4
- data.tar.gz: 7ca731224fd6a2332d76502d507b9ba6e71ffd55
3
+ metadata.gz: 962054153165b37bfaa93698bcca7f2ba38dfd9a
4
+ data.tar.gz: 11343b5d76e7d144c2358f542bf31d012ee3f0f5
5
5
  SHA512:
6
- metadata.gz: f26676d41f1f05638d9fda5a5bb44798c4e8e9196be7384b54b70e761c8705a11a2c591e84e20808a1346e9d616f1f2956b2ac2b6d1c6c87fa258fc14578fb37
7
- data.tar.gz: 9f22581830ff0349e7dcc79ce1732ed80d97a232b654172d454f1aa84a6cb1ea2fdc3c2341197d5d622452f51391821402ee0b76db681b645d802d89ea7a2d5f
6
+ metadata.gz: ea7381d2b081165d5e2c7817a193234e9909c48e634d74156ff23739c5b5ceffdaa7843bf79699154aacb9e4e6aad9066df5b48017a2b3ef7450c9ac48ca931a
7
+ data.tar.gz: 987f9a7c698a1d3957a07e76c87402c59a35c8e9f760e7d8fd7a0bd47af327191a70ed4fcbdaa287bf1a64baed27b7e5bcb508e31222ff74162f00ba98d28136
@@ -120,7 +120,7 @@ module Api
120
120
  when 'includes'
121
121
  scope = scope.includes(condition.map(&:to_sym))
122
122
  else
123
- condition_statement = ::Api::ResourcesController::ConditionParser.new(field, condition).condition_statement
123
+ condition_statement = ::Api::ResourcesController::ConditionParser.new(scope, field, condition).condition_statement
124
124
  scope = scope.where(condition_statement)
125
125
  end
126
126
  end
@@ -10,8 +10,8 @@ module Api
10
10
  lt: :<
11
11
  }
12
12
 
13
- def initialize(field, condition)
14
- @field, @condition = field, condition
13
+ def initialize(scope, field, condition)
14
+ @scope, @field, @condition = scope, field, condition
15
15
  end
16
16
 
17
17
  def condition_statement
@@ -23,7 +23,11 @@ module Api
23
23
  def build_condition_statement(parent_key, condition, nested = false)
24
24
  if is_a_condition?(parent_key) && !nested
25
25
  column, operator = extract_column_and_operator(parent_key)
26
- ["#{column} = ?", condition]
26
+ if column_is_boolean?(column)
27
+ ["#{column} = ?", to_boolean(condition)]
28
+ else
29
+ ["#{column} = ?", condition]
30
+ end
27
31
  else
28
32
  if nested
29
33
  column = extract_column(parent_key)
@@ -59,6 +63,14 @@ module Api
59
63
  def operator_map
60
64
  OPERATOR_MAP
61
65
  end
66
+
67
+ def column_is_boolean?(column_name)
68
+ @scope.columns_hash[column_name].type == :boolean
69
+ end
70
+
71
+ def to_boolean(string)
72
+ ActiveRecord::ConnectionAdapters::Column.value_to_boolean(string)
73
+ end
62
74
  end
63
75
  end
64
76
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module AddOns
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-add_ons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-28 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails