trailblazer-finder 0.10.1 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +16 -0
  3. data/.rubocop.yml +7 -1
  4. data/CHANGES.md +15 -0
  5. data/Gemfile +3 -1
  6. data/README.md +4 -4
  7. data/Rakefile +0 -6
  8. data/lib/trailblazer/finder/activities/find.rb +20 -21
  9. data/lib/trailblazer/finder/activities/prepare.rb +2 -3
  10. data/lib/trailblazer/finder/activities/prepare_adapter.rb +25 -0
  11. data/lib/trailblazer/finder/activities/prepare_entity.rb +5 -5
  12. data/lib/trailblazer/finder/activities/prepare_paging.rb +5 -11
  13. data/lib/trailblazer/finder/activities/prepare_params.rb +3 -3
  14. data/lib/trailblazer/finder/activities/prepare_properties.rb +1 -5
  15. data/lib/trailblazer/finder/activities/prepare_sorting.rb +3 -8
  16. data/lib/trailblazer/finder/activities/process.rb +0 -1
  17. data/lib/trailblazer/finder/activities/process_adapters.rb +25 -23
  18. data/lib/trailblazer/finder/adapters/active_record/paging.rb +1 -1
  19. data/lib/trailblazer/finder/adapters/active_record/predicates.rb +14 -14
  20. data/lib/trailblazer/finder/adapters/active_record/sorting.rb +1 -1
  21. data/lib/trailblazer/finder/adapters/basic/paging.rb +1 -1
  22. data/lib/trailblazer/finder/adapters/basic/predicates.rb +14 -14
  23. data/lib/trailblazer/finder/adapters/basic/sorting.rb +1 -1
  24. data/lib/trailblazer/finder/adapters/kaminari/paging.rb +2 -3
  25. data/lib/trailblazer/finder/adapters/sequel/paging.rb +1 -1
  26. data/lib/trailblazer/finder/adapters/sequel/predicates.rb +14 -14
  27. data/lib/trailblazer/finder/adapters/sequel/sorting.rb +1 -1
  28. data/lib/trailblazer/finder/adapters/will_paginate/paging.rb +2 -3
  29. data/lib/trailblazer/finder/dsl.rb +12 -9
  30. data/lib/trailblazer/finder/find.rb +4 -2
  31. data/lib/trailblazer/finder/helpers/sorting.rb +4 -1
  32. data/lib/trailblazer/finder/version.rb +1 -1
  33. data/lib/trailblazer/finder.rb +1 -7
  34. data/lib/trailblazer/operation/finder.rb +3 -3
  35. data/spec/spec_helper.rb +0 -1
  36. data/spec/trailblazer/finder/adapters/active_record_spec.rb +5 -5
  37. data/spec/trailblazer/finder/adapters/basic_spec.rb +12 -3
  38. data/spec/trailblazer/finder/adapters/kaminari_spec.rb +13 -8
  39. data/spec/trailblazer/finder/adapters/sequel_spec.rb +5 -5
  40. data/spec/trailblazer/finder/adapters/will_paginate_spec.rb +12 -7
  41. data/spec/trailblazer/finder/dsl_spec.rb +4 -13
  42. data/spec/trailblazer/operation/finder_spec.rb +18 -3
  43. data/trailblazer-finder.gemspec +4 -5
  44. metadata +21 -36
  45. data/.rubocop_todo.yml +0 -78
  46. data/.travis.yml +0 -7
  47. data/lib/trailblazer/finder/activities/prepare_adapters.rb +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 691fee589f1865e7704d021751dfedfa6be1c51950f5812b09de57493ac2d6e4
4
- data.tar.gz: 1919763290c8173d600c4722fa6c1c43a4be4bd70715cc1d05efb963ba5af78b
3
+ metadata.gz: 39f554fa2720ae7fe8f7bdc61eb44e636167a7ec85cb4c0b47da5027f80d4c3e
4
+ data.tar.gz: 83e4e41732b0c4fef9d4d5793e3f6de7ad6b66086c906854127e6018f7a7eaa5
5
5
  SHA512:
6
- metadata.gz: 3215baeb3874a0aafe6eb0f4c65f28848ebb08806f26a76e195eb8b9fc9bf8e087a6f64e126ca5d7f0981c42f1cedde892e27e8d882ed799d7ee9e84771d05d8
7
- data.tar.gz: ec4f69e4f75bac9d921bf503381afab35073d0806c65dfd1b1af4382e82ae51f9199098366898429f0dd3f6c22da2dd7977b17bcd8f5b03d08f1a0748cbf19d4
6
+ metadata.gz: d8e69bb8c68980e657d2399fb1e6b50d63b1538e38346eb1a40465e60737940f431c052689a29c3b4ca9fdfc69b6e7d26f49f59db015e30beb5ba736522e81e5
7
+ data.tar.gz: 9fe89ed1a67614bff0a9d5a69242972ce4bd219b0d20e72bb0d356637f7dbc9c2f3ea6e27fd32eb42c32e5502e67716545f4be5e9498a3d94c3863c92e4db1e0
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ ruby: [2.5, 2.6, 2.7, '3.0']
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: ${{ matrix.ruby }}
15
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
16
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -2,4 +2,10 @@ require: rubocop-rspec
2
2
 
3
3
  inherit_from:
4
4
  - https://raw.githubusercontent.com/trailblazer/meta/master/rubocop.yml
5
- - .rubocop_todo.yml
5
+
6
+ RSpec/ExampleLength:
7
+ Enabled: false
8
+ RSpec/MultipleExpectations:
9
+ Enabled: false
10
+ Layout/LineLength:
11
+ Enabled: false
data/CHANGES.md CHANGED
@@ -1,3 +1,18 @@
1
+ # 0.70.0
2
+ * Drop Support Legacy Dry-types
3
+
4
+ # 0.60.0
5
+ * Support Ruby 3.0
6
+
7
+ # 0.50.0
8
+ * Breaking change: Use adapter and paginator configs instead of mixing them in adapters config.
9
+
10
+ # 0.10.3
11
+ * Add support for strings in filters keys.
12
+
13
+ # 0.10.2
14
+ * Add support for ActiveSupport::Hash as params
15
+
1
16
  # 0.10.1
2
17
  * Move activities to Activities folder to avoid conflict with Activity Class.
3
18
 
data/Gemfile CHANGED
@@ -4,7 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "pry-byebug"
7
+ gem "debug", platform: :mri
8
+ gem "jdbc-sqlite3", :platform => :jruby
9
+ gem "sqlite3", platform: :mri
8
10
 
9
11
  # Had to add this for a bit, since none of the latest changes have been pushed to gems yet
10
12
  # gem "trailblazer", github: "trailblazer/trailblazer"
data/README.md CHANGED
@@ -78,7 +78,7 @@ Basically for most use cases, Entity is the entity/model/array of hashes you wis
78
78
  ```ruby
79
79
  class Post::Finder < Trailblazer::Finder
80
80
  # Without defining an ORM everything defaults to dealing with hash objects
81
- adapters :ActiveRecord
81
+ adapter :ActiveRecord
82
82
 
83
83
  # Optional if you use it as option in the caller, Model/Entity or Array with Hashes
84
84
  entity { Post }
@@ -364,7 +364,7 @@ You can specify the adapters you wish to use inside your enherited Finder class.
364
364
  ### Adapters Example
365
365
  ```ruby
366
366
  class Post::Finder < Trailblazer::Finder
367
- adapters :ActiveRecord
367
+ adapter "ActiveRecord"
368
368
  end
369
369
  ```
370
370
 
@@ -374,7 +374,7 @@ The only thing the [ActiveRecord](https://github.com/rails/rails/tree/master/act
374
374
  #### Active Record Example
375
375
  ```ruby
376
376
  class Post::Finder < Trailblazer::Finder
377
- adapters :ActiveRecord
377
+ adapter "ActiveRecord"
378
378
  end
379
379
  ```
380
380
 
@@ -384,7 +384,7 @@ The only thing the [Sequel](https://github.com/jeremyevans/sequel) adapter does,
384
384
  #### Sequel Example
385
385
  ```ruby
386
386
  class Post::Finder < Trailblazer::Finder
387
- adapters :Sequel
387
+ adapter "Sequel"
388
388
  end
389
389
  ```
390
390
 
data/Rakefile CHANGED
@@ -16,12 +16,6 @@ end
16
16
 
17
17
  RuboCop::RakeTask.new(:rubocop)
18
18
 
19
- desc "Remove temporary files"
20
- task :clean do
21
- `rm -rf *.gem doc pkg coverage test-reports`
22
- %x(rm -f `find . -name '*.rbc'`)
23
- end
24
-
25
19
  desc "Build the gem"
26
20
  task :gem do
27
21
  `gem build trailblazer-finder.gemspec`
@@ -3,21 +3,19 @@
3
3
  module Trailblazer
4
4
  class Finder
5
5
  module Activities
6
- # Find Activity
7
6
  class Find < Trailblazer::Activity::Railway
8
7
  PREDICATES = %w[eq not_eq blank not_blank lt lte gt gte sw not_sw ew not_ew cont not_cont].freeze
9
8
 
10
-
11
- def process_params(ctx, params:, **)
9
+ def process_params(ctx, params:, **)
12
10
  params.each do |attribute, value|
13
11
  result = {}
14
-
15
- fetch_filters(ctx, result, attribute) || result if ctx[:filters].include?(attribute)
16
- fetch_properties(result, attribute, value, ctx[:properties]) || result
12
+ filter_attribute = attribute.to_sym
13
+ fetch_filters(ctx, result, filter_attribute) || result if ctx[:filters].include?(filter_attribute)
14
+ fetch_properties(result, filter_attribute, value, ctx[:properties]) || result
17
15
  next ctx[:params].delete(attribute) if result.empty?
18
16
 
19
17
  ctx[:process] ||= {}
20
- ctx[:process][attribute] = result.merge!(value: value)
18
+ ctx[:process][filter_attribute] = result.merge!(value: value)
21
19
  end
22
20
  true
23
21
  end
@@ -32,23 +30,24 @@ module Trailblazer
32
30
  step :set_finder
33
31
 
34
32
  private
35
- def fetch_filters(ctx, result, attribute)
36
- filter_attribute = ctx[:filters][attribute]
37
- result[:filter] = {}
38
- result[:name] = attribute
39
- result[:filter][:handler] = filter_attribute[:with] || filter_attribute[:block]
40
- end
41
33
 
42
- def fetch_properties(result, attribute, value, properties)
43
- splitter = Utils::Splitter.new attribute, value
44
- PREDICATES.each do |predicate|
45
- next unless splitter.split_key predicate
46
- next unless properties.include?(splitter.field.to_sym)
34
+ def fetch_filters(ctx, result, attribute)
35
+ filter_attribute = ctx[:filters][attribute]
36
+ result[:filter] = {}
37
+ result[:name] = attribute
38
+ result[:filter][:handler] = filter_attribute[:with] || filter_attribute[:block]
39
+ end
40
+
41
+ def fetch_properties(result, attribute, value, properties)
42
+ splitter = Utils::Splitter.new attribute, value
43
+ PREDICATES.each do |predicate|
44
+ next unless splitter.split_key predicate
45
+ next unless properties.include?(splitter.field.to_sym)
47
46
 
48
- result[:name] = splitter.field
49
- result[:predicate] = predicate
50
- end
47
+ result[:name] = splitter.field
48
+ result[:predicate] = predicate
51
49
  end
50
+ end
52
51
  end
53
52
  end
54
53
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "prepare_adapters"
3
+ require_relative "prepare_adapter"
4
4
  require_relative "prepare_entity"
5
5
  require_relative "prepare_properties"
6
6
  require_relative "prepare_filters"
@@ -11,14 +11,13 @@ require_relative "prepare_sorting"
11
11
  module Trailblazer
12
12
  class Finder
13
13
  module Activities
14
- # Prepare Activity
15
14
  class Prepare < Trailblazer::Activity::Railway
16
15
  def clean_ctx((ctx, flow_options), **)
17
16
  ctx.delete(:options)
18
17
  [Activity::Right, [ctx, flow_options]]
19
18
  end
20
19
 
21
- step Subprocess(PrepareAdapters)
20
+ step Subprocess(PrepareAdapter)
22
21
  step Subprocess(PrepareEntity)
23
22
  step Subprocess(PrepareProperties)
24
23
  step Subprocess(PrepareFilters)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trailblazer
4
+ class Finder
5
+ module Activities
6
+ class PrepareAdapter < Trailblazer::Activity::Railway
7
+ def set_adapter(ctx, **)
8
+ ctx[:adapter] = ctx.dig(:config, :adapter) || "Basic"
9
+ end
10
+
11
+ def validate_adapter(_ctx, adapter:, **)
12
+ (ORM_ADAPTERS + ["Basic"]).include? adapter.to_s
13
+ end
14
+
15
+ def invalid?((ctx, _flow_options), **_circuit_options)
16
+ (ctx[:errors] ||= []) << {adapter: "The specified adapter are invalid"}
17
+ end
18
+
19
+ step :set_adapter
20
+ step :validate_adapter
21
+ fail :invalid?
22
+ end
23
+ end
24
+ end
25
+ end
@@ -5,7 +5,7 @@ module Trailblazer
5
5
  module Activities
6
6
  class PrepareEntity < Trailblazer::Activity::Railway
7
7
  def validate_entity(ctx, **)
8
- ctx.dig(:options,:entity) || ctx.dig(:config,:entity)
8
+ ctx.dig(:options, :entity) || ctx.dig(:config, :entity)
9
9
  end
10
10
 
11
11
  def invalid_entity_error(ctx, **)
@@ -13,12 +13,12 @@ module Trailblazer
13
13
  end
14
14
 
15
15
  def set_entity(ctx, **)
16
- ctx[:entity] = ctx.dig(:options,:entity) || instance_eval(&ctx[:config][:entity])
16
+ ctx[:entity] = ctx.dig(:options, :entity) || instance_eval(&ctx[:config][:entity])
17
17
  end
18
18
 
19
- step (:validate_entity)
20
- fail (:invalid_entity_error)
21
- step (:set_entity)
19
+ step :validate_entity
20
+ fail :invalid_entity_error
21
+ step :set_entity
22
22
  end
23
23
  end
24
24
  end
@@ -12,8 +12,8 @@ module Trailblazer
12
12
  end
13
13
 
14
14
  def set_paging(ctx, **)
15
- ctx[:paging] = ctx.dig(:config,:paging) || {}
16
- ctx[:paging][:current_page] = ctx.dig(:params,:page) || 1
15
+ ctx[:paging] = ctx.dig(:config, :paging) || {}
16
+ ctx[:paging][:current_page] = ctx.dig(:params, :page) || 1
17
17
  return true unless ctx[:params][:per_page]
18
18
 
19
19
  ctx[:paging][:per_page] = ctx[:params][:per_page].to_i || ctx[:paging][:per_page]
@@ -27,15 +27,9 @@ module Trailblazer
27
27
  true
28
28
  end
29
29
 
30
- step (:check_paging),
31
- Output(:failure) => Track(:end_paging)
32
- step (:set_paging),
33
- Output(:success) => Track(:end_paging),
34
- Output(:failure) => Track(:failure)
35
- step (:clear_paging),
36
- magnetic_to: :end_paging,
37
- Output(:success) => Track(:success),
38
- Output(:failure) => Track(:failure)
30
+ step :check_paging, Output(:failure) => Track(:end_paging)
31
+ step :set_paging
32
+ step :clear_paging, magnetic_to: :end_paging
39
33
  end
40
34
  end
41
35
  end
@@ -18,9 +18,9 @@ module Trailblazer
18
18
  ctx[:params] = ctx[:options][:params] || {}
19
19
  end
20
20
 
21
- step (:validate_params)
22
- fail (:invalid_params_error)
23
- step (:set_params)
21
+ step :validate_params
22
+ fail :invalid_params_error
23
+ step :set_params
24
24
  end
25
25
  end
26
26
  end
@@ -18,11 +18,7 @@ module Trailblazer
18
18
  return true if properties.empty?
19
19
 
20
20
  properties.each do |key, _value|
21
- if LEGACY_DRY_TYPES
22
- return properties[key][:type].class.ancestors.include?(::Dry::Types::Definition)
23
- else
24
- return properties[key][:type].class.ancestors.include?(::Dry::Types::Nominal)
25
- end
21
+ return properties[key][:type].class.ancestors.include?(::Dry::Types::Nominal)
26
22
  end
27
23
  end
28
24
 
@@ -37,15 +37,10 @@ module Trailblazer
37
37
  true
38
38
  end
39
39
 
40
- step (:check_sorting),
41
- Output(:success) => Track(:paging),
40
+ step :check_sorting,
42
41
  Output(:failure) => Track(:end_sorting)
43
- step (:set_sorting),
44
- magnetic_to: :paging,
45
- Output(:success) => Track(:end_sorting),
46
- Output(:failure) => Track(:failure)
47
- step (:clear_sorting),
48
- magnetic_to: :end_sorting
42
+ step :set_sorting
43
+ step :clear_sorting, magnetic_to: :end_sorting
49
44
  end
50
45
  end
51
46
  end
@@ -9,7 +9,6 @@ require_relative "process_filters"
9
9
  module Trailblazer
10
10
  class Finder
11
11
  module Activities
12
- # Process Activity
13
12
  class Process < Trailblazer::Activity::Railway
14
13
  step Subprocess(ProcessAdapters)
15
14
  step Subprocess(ProcessPredicates)
@@ -4,36 +4,38 @@ module Trailblazer
4
4
  class Finder
5
5
  module Activities
6
6
  class ProcessAdapters < Trailblazer::Activity::Railway
7
- def set_orm_adapters(ctx, **)
8
- ctx[:adapters].each do |adapter|
9
- next unless (ORM_ADAPTERS + ["Basic"]).include?(adapter)
10
-
11
- ctx[:orm] = {}
12
- ctx[:orm][:adapter] = adapter
13
- ctx[:orm][:predicates] = "Trailblazer::Finder::Adapters::#{adapter}::Predicates"
14
- ctx[:orm][:paging] = "Trailblazer::Finder::Adapters::#{adapter}::Paging"
15
- ctx[:orm][:sorting] = "Trailblazer::Finder::Adapters::#{adapter}::Sorting"
16
- return true
17
- end
7
+ def set_adapter((ctx, _flow_options), **)
8
+ adapter = ctx[:adapter]
9
+ ctx[:orm] = {}
10
+ ctx[:orm][:adapter] = adapter
11
+ ctx[:orm][:predicates] = "Trailblazer::Finder::Adapters::#{adapter}::Predicates"
12
+ ctx[:orm][:paging] = "Trailblazer::Finder::Adapters::#{adapter}::Paging"
13
+ ctx[:orm][:sorting] = "Trailblazer::Finder::Adapters::#{adapter}::Sorting"
14
+ true
18
15
  end
19
16
 
20
- def set_paging_adapters(ctx, **)
21
- ctx[:adapters].each do |adapter|
22
- next unless PAGING_ADAPTERS.include?(adapter)
23
- return false if ctx[:adapters].include?("Basic")
24
- ctx[:orm][:paging] = "Trailblazer::Finder::Adapters::#{adapter}::Paging"
25
- return true
26
- end
17
+ def set_paginator(ctx, **)
18
+ paginator = ctx.dig(:config, :paginator)
19
+ return true unless paginator
20
+ return false unless ORM_ADAPTERS.include?(ctx[:orm][:adapter])
21
+ return false unless PAGING_ADAPTERS.include?(paginator)
22
+
23
+ ctx[:orm][:paging] = "Trailblazer::Finder::Adapters::#{paginator}::Paging"
27
24
  true
28
25
  end
29
26
 
30
- def invalid_paging_adapter_error(ctx, **)
31
- (ctx[:errors] ||= []) << {adapters: "Can't use paging adapters like Kaminari without using an ORM like ActiveRecord or Sequel"}
27
+ def invalid_paginator_error(ctx, **)
28
+ (ctx[:errors] ||= []) << {
29
+ paginator: "Can't use paginator #{ctx.dig(
30
+ :config,
31
+ :paginator
32
+ )} without using an ORM like ActiveRecord or Sequel"
33
+ }
32
34
  end
33
35
 
34
- step :set_orm_adapters
35
- step :set_paging_adapters
36
- fail :invalid_paging_adapter_error
36
+ step :set_adapter, fast_track: true
37
+ step :set_paginator
38
+ fail :invalid_paginator_error
37
39
  end
38
40
  end
39
41
  end
@@ -10,7 +10,7 @@ module Trailblazer
10
10
  module_function
11
11
 
12
12
  def set_paging_handler
13
- lambda do |current_page, per_page, entity|
13
+ ->(current_page, per_page, entity) do
14
14
  entity.limit(per_page).offset(([current_page, 1].max - 1) * per_page)
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ module Trailblazer
10
10
  module_function
11
11
 
12
12
  def set_eq_handler
13
- lambda do |entity, attribute, value|
13
+ ->(entity, attribute, value) do
14
14
  return if Utils::String.blank?(value.to_s)
15
15
 
16
16
  entity.where(attribute => value)
@@ -18,7 +18,7 @@ module Trailblazer
18
18
  end
19
19
 
20
20
  def set_not_eq_handler
21
- lambda do |entity, attribute, value|
21
+ ->(entity, attribute, value) do
22
22
  return if Utils::String.blank?(value.to_s)
23
23
 
24
24
  entity.where.not(attribute => value)
@@ -26,73 +26,73 @@ module Trailblazer
26
26
  end
27
27
 
28
28
  def set_blank_handler
29
- lambda do |entity, attribute, _value|
29
+ ->(entity, attribute, _value) do
30
30
  entity.where(attribute.to_sym => [nil, ""])
31
31
  end
32
32
  end
33
33
 
34
34
  def set_not_blank_handler
35
- lambda do |entity, attribute, _value|
35
+ ->(entity, attribute, _value) do
36
36
  entity.where.not(attribute.to_sym => [nil, ""])
37
37
  end
38
38
  end
39
39
 
40
40
  def set_gt_handler
41
- lambda do |entity, attribute, value|
41
+ ->(entity, attribute, value) do
42
42
  entity.where("#{attribute} > ?", value.to_f)
43
43
  end
44
44
  end
45
45
 
46
46
  def set_gte_handler
47
- lambda do |entity, attribute, value|
47
+ ->(entity, attribute, value) do
48
48
  entity.where("#{attribute} >= ?", value.to_f)
49
49
  end
50
50
  end
51
51
 
52
52
  def set_lt_handler
53
- lambda do |entity, attribute, value|
53
+ ->(entity, attribute, value) do
54
54
  entity.where("#{attribute} < ?", value.to_f)
55
55
  end
56
56
  end
57
57
 
58
58
  def set_lte_handler
59
- lambda do |entity, attribute, value|
59
+ ->(entity, attribute, value) do
60
60
  entity.where("#{attribute} <= ?", value.to_f)
61
61
  end
62
62
  end
63
63
 
64
64
  def set_cont_handler
65
- lambda do |entity, attribute, value|
65
+ ->(entity, attribute, value) do
66
66
  entity.where("#{attribute} LIKE ?", "%#{value}%")
67
67
  end
68
68
  end
69
69
 
70
70
  def set_not_cont_handler
71
- lambda do |entity, attribute, value|
71
+ ->(entity, attribute, value) do
72
72
  entity.where("#{attribute} NOT LIKE ?", "%#{value}%")
73
73
  end
74
74
  end
75
75
 
76
76
  def set_sw_handler
77
- lambda do |entity, attribute, value|
77
+ ->(entity, attribute, value) do
78
78
  entity.where("#{attribute} LIKE ?", "#{value}%")
79
79
  end
80
80
  end
81
81
 
82
82
  def set_not_sw_handler
83
- lambda do |entity, attribute, value|
83
+ ->(entity, attribute, value) do
84
84
  entity.where("#{attribute} NOT LIKE ?", "#{value}%")
85
85
  end
86
86
  end
87
87
 
88
88
  def set_ew_handler
89
- lambda do |entity, attribute, value|
89
+ ->(entity, attribute, value) do
90
90
  entity.where("#{attribute} LIKE ?", "%#{value}")
91
91
  end
92
92
  end
93
93
 
94
94
  def set_not_ew_handler
95
- lambda do |entity, attribute, value|
95
+ ->(entity, attribute, value) do
96
96
  entity.where("#{attribute} NOT LIKE ?", "%#{value}")
97
97
  end
98
98
  end
@@ -10,7 +10,7 @@ module Trailblazer
10
10
  module_function
11
11
 
12
12
  def set_sorting_handler
13
- lambda do |sort_attributes, entity|
13
+ ->(sort_attributes, entity) do
14
14
  sort_attributes.delete(:handler)
15
15
  attributes = []
16
16
  sort_attributes.each do |attr|
@@ -10,7 +10,7 @@ module Trailblazer
10
10
  module_function
11
11
 
12
12
  def set_paging_handler
13
- lambda do |current_page, per_page, entity|
13
+ ->(current_page, per_page, entity) do
14
14
  entity.drop(([current_page, 1].max - 1) * per_page).first(per_page)
15
15
  end
16
16
  end