active_hash_relation 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 3ec68ab5e18f7bc44eec9467db50faa96931ad2a
4
- data.tar.gz: 826437be41a6a2b00211e9478c3a4e8f7e6a988b
3
+ metadata.gz: e715e9a37b308b7349d0d842fdd7ce7df39b005a
4
+ data.tar.gz: 54a6f94ae717a4acaa2f8dab2ad0481dd96fe0ab
5
5
  SHA512:
6
- metadata.gz: b1cf943d7e8897e36528cf6e9f9eccf001d89599b910d0490a0257f60ea4fcd37a15503b44643a9a00b8ba0a37656ac45ecabd024fdffeb228d848fc305b8a27
7
- data.tar.gz: 1bafc8c4413896982e8df7258acc8e2030d2e711826c551309921a17c25c21cdb4a4319d9d0ee8e4a919c73cff27aba586e11da50881968a4119a5a6379b1288
6
+ metadata.gz: f497e1de1028dfbd9cd5b2c10fd61cf772726edd8b6370570c43ba074bce7748e7f061ec52d29524ea50cb94f43bb2b6421e14ac1e1c56d298860a954f3cd366
7
+ data.tar.gz: b764c826ccef44218ff0efc522e23815af586dc5c6e48090909bb9156ce510c9ab218083b39df34c4f38891fcb521631af731caf516ed39fbddacd45c121f891
@@ -8,17 +8,31 @@ module ActiveHashRelation::AssociationFilters
8
8
  if params[association]
9
9
  association_name = association.to_s.titleize.split.join
10
10
  if self.configuration.has_filter_classes
11
- puts self.filter_class(association_name)
12
- association_filters = self.filter_class(association_name).new(
13
- association_name.singularize.constantize.all,
14
- params[association]
15
- ).apply_filters
11
+ if self.configuration.use_unscoped
12
+ association_filters = self.filter_class(association_name).new(
13
+ association_name.singularize.constantize.unscoped.all,
14
+ params[association]
15
+ ).apply_filters
16
+ else
17
+ association_filters = self.filter_class(association_name).new(
18
+ association_name.singularize.constantize.all,
19
+ params[association]
20
+ ).apply_filters
21
+ end
16
22
  else
17
- association_filters = ActiveHashRelation::FilterApplier.new(
18
- association_name.singularize.constantize.all,
19
- params[association],
20
- include_associations: true
21
- ).apply_filters
23
+ if self.configuration.use_unscoped
24
+ association_filters = ActiveHashRelation::FilterApplier.new(
25
+ association_name.singularize.constantize.unscoped.all,
26
+ params[association],
27
+ include_associations: true
28
+ ).apply_filters
29
+ else
30
+ association_filters = ActiveHashRelation::FilterApplier.new(
31
+ association_name.singularize.constantize.all,
32
+ params[association],
33
+ include_associations: true
34
+ ).apply_filters
35
+ end
22
36
  end
23
37
  resource = resource.joins(association).merge(association_filters)
24
38
  end
@@ -48,7 +48,7 @@ module ActiveHashRelation::ColumnFilters
48
48
  end
49
49
 
50
50
  def filter_boolean(resource, column, param)
51
- b_param = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(param)
51
+ b_param = ActiveRecord::Type::Boolean.new.type_cast_from_database(param)
52
52
 
53
53
  resource = resource.where(column => b_param)
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveHashRelation
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -40,6 +40,7 @@ module ActiveHashRelation
40
40
  end
41
41
 
42
42
  class Configuration
43
- attr_accessor :has_filter_classes, :filter_class_prefix, :filter_class_suffix
43
+ attr_accessor :has_filter_classes, :filter_class_prefix, :filter_class_suffix,
44
+ :use_unscoped
44
45
  end
45
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hash_relation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filippos Vasilakis