granite 0.12.0 → 0.12.1

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: 8f01fbcec194a3031c22582899a7ff0210d2b621aa149a5ccf7814a3a70540ea
4
- data.tar.gz: c763544b18d4feb43a5502df2e661dce313c304f47543978be095e4e72afc863
3
+ metadata.gz: 52d8a88997b67bfb217a38ca0cc018dc73643b9bc3c6a6cae2360faba4df0733
4
+ data.tar.gz: c544a8f9581989a4bb9aa46e31bba7ea41ad69275475d68dfb94ccffb12302e2
5
5
  SHA512:
6
- metadata.gz: '099c76956322fe11a1118dc25a1fffbc0553018d1abf660d7c6270256f40505a3d93be01e57df0d7502c767c09d961fcf3361a7281315296e6abb9c512a38a9f'
7
- data.tar.gz: 9b1b66eca75f4ff623319d1828cbec2b987c36050fb70598a8a14ea7edd760da38eb61c89f0a4de3b706875b68a16dccefe22333c3ac8edbe5b80864e04f4aca
6
+ metadata.gz: 2b66c8f502e7010349f5a75cdcd641010ee415797c7ae91e1b6b292501910e1001ba102280f407b75863eef3851eaff7e4c851fd03620930af340929ceeac61c
7
+ data.tar.gz: '08d61d57ebe13e3e40176d93a2dc4554606c998e8855f498338707faa455ad03e90cefee322141e6679e5a2c37ce27ab485646e166834c01d4a4ac364f557eae'
@@ -7,7 +7,7 @@ module Granite
7
7
  class_attribute :_exception_handlers, instance_writer: false
8
8
  self._exception_handlers = {}
9
9
 
10
- protected :_exception_handlers # rubocop:disable Style/AccessModifierDeclarations
10
+ protected :_exception_handlers
11
11
  end
12
12
 
13
13
  module ClassMethods
@@ -98,8 +98,8 @@ module Granite
98
98
  end
99
99
 
100
100
  # Adds passed error message and options to `errors` object
101
- def decline_with(*args)
102
- errors.add(:base, *args)
101
+ def decline_with(*args, **kwargs)
102
+ errors.add(:base, *args, **kwargs)
103
103
  failed_preconditions << args.first
104
104
  end
105
105
 
@@ -85,13 +85,13 @@ module Granite
85
85
  _projectors.store(name, options, &block)
86
86
 
87
87
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
88
- def self.#{name}
89
- _projectors.fetch(:#{name})
90
- end
91
-
92
- def #{name}
93
- @#{name} ||= self.class._projectors.fetch(:#{name}).new(self)
94
- end
88
+ def self.#{name} # def self.foo
89
+ _projectors.fetch(:#{name}) # _projectors.fetch(:foo)
90
+ end # end
91
+ #
92
+ def #{name} # def foo
93
+ @#{name} ||= self.class._projectors.fetch(:#{name}).new(self) # @foo ||= self.class._projectors.fetch(:foo).new(self)
94
+ end # end
95
95
  METHOD
96
96
  end
97
97
  end
@@ -62,11 +62,9 @@ module Granite
62
62
  collected_errors = []
63
63
 
64
64
  callbacks.reverse_each do |callback|
65
- begin
66
- callback.respond_to?(:run_callbacks) ? callback.run_callbacks(:commit) : callback.call
67
- rescue StandardError => e
68
- collected_errors << e
69
- end
65
+ callback.respond_to?(:run_callbacks) ? callback.run_callbacks(:commit) : callback.call
66
+ rescue StandardError => e
67
+ collected_errors << e
70
68
  end
71
69
 
72
70
  return unless collected_errors.any?
@@ -17,7 +17,7 @@ module Granite
17
17
 
18
18
  def translate(*args, **options)
19
19
  key, options = Granite::Translations.scope_translation_args(self.class.i18n_scopes, *args, **options)
20
- I18n.translate(key, **options)
20
+ I18n.t(key, **options)
21
21
  end
22
22
  alias t translate
23
23
  end
@@ -1,6 +1,6 @@
1
1
  module Granite
2
2
  module AssignData
3
- DataAssignment = Struct.new(:method, :options)
3
+ DataAssignment = Struct.new(:method, :options) # rubocop:disable Lint/StructNewOverride
4
4
 
5
5
  extend ActiveSupport::Concern
6
6
 
@@ -9,7 +9,7 @@ module Granite
9
9
  self.data_assignments = []
10
10
 
11
11
  alias_method :only_run_validations!, :run_validations!
12
- protected :only_run_validations! # rubocop:disable Style/AccessModifierDeclarations
12
+ protected :only_run_validations!
13
13
  end
14
14
 
15
15
  module ClassMethods
@@ -22,13 +22,13 @@ module Granite
22
22
  self.controller_actions = controller_actions.merge(name.to_sym => options)
23
23
  controller_class.__send__(:define_method, name, &block)
24
24
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
25
- def #{name}_url(options = {})
26
- action_url(:#{name}, **options.symbolize_keys)
27
- end
28
-
29
- def #{name}_path(options = {})
30
- action_path(:#{name}, **options.symbolize_keys)
31
- end
25
+ def #{name}_url(options = {}) # def foo_url(options = {}
26
+ action_url(:#{name}, **options.symbolize_keys) # action_url(:foo, **options.symbolize_keys)
27
+ end # end
28
+ #
29
+ def #{name}_path(options = {}) # def foo_path(options = {})
30
+ action_path(:#{name}, **options.symbolize_keys) # action_path(:foo, **options.symbolize_keys)
31
+ end # end
32
32
  METHOD
33
33
  else
34
34
  controller_actions[name.to_sym]
@@ -15,7 +15,7 @@ module Granite
15
15
  end
16
16
 
17
17
  def typecast(value)
18
- return value if value.class == type
18
+ return value if value.class == type # rubocop:disable Style/ClassEqualityComparison
19
19
 
20
20
  typecaster.call(value, self) unless value.nil?
21
21
  end
@@ -28,9 +28,9 @@ module Granite
28
28
 
29
29
  def typecaster
30
30
  @typecaster ||= begin
31
- type_class = type.instance_of?(Class) ? type : type.class
32
- @typecaster = ActiveData.typecaster(type_class.ancestors.grep(Class))
33
- end
31
+ type_class = type.instance_of?(Class) ? type : type.class
32
+ @typecaster = ActiveData.typecaster(type_class.ancestors.grep(Class))
33
+ end
34
34
  end
35
35
 
36
36
  def changed?
@@ -23,14 +23,12 @@ RSpec::Matchers.define :raise_validation_error do
23
23
  end
24
24
 
25
25
  match do |block|
26
- begin
27
- block.call
28
- false
29
- rescue Granite::Action::ValidationError => e
30
- @details = e.errors.details
31
- @details_being_checked = @details[@attribute || :base]
32
- @result = @details_being_checked&.any? { |x| x[:error] == @error_type }
33
- end
26
+ block.call
27
+ false
28
+ rescue Granite::Action::ValidationError => e
29
+ @details = e.errors.details
30
+ @details_being_checked = @details[@attribute || :base]
31
+ @result = @details_being_checked&.any? { |x| x[:error] == @error_type }
34
32
  end
35
33
 
36
34
  description do
@@ -1,3 +1,3 @@
1
1
  module Granite
2
- VERSION = '0.12.0'.freeze
2
+ VERSION = '0.12.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toptal Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -252,42 +252,42 @@ dependencies:
252
252
  requirements:
253
253
  - - "~>"
254
254
  - !ruby/object:Gem::Version
255
- version: 0.78.0
255
+ version: '1.0'
256
256
  type: :development
257
257
  prerelease: false
258
258
  version_requirements: !ruby/object:Gem::Requirement
259
259
  requirements:
260
260
  - - "~>"
261
261
  - !ruby/object:Gem::Version
262
- version: 0.78.0
262
+ version: '1.0'
263
263
  - !ruby/object:Gem::Dependency
264
264
  name: rubocop-rails
265
265
  requirement: !ruby/object:Gem::Requirement
266
266
  requirements:
267
267
  - - "~>"
268
268
  - !ruby/object:Gem::Version
269
- version: 2.4.1
269
+ version: '2.13'
270
270
  type: :development
271
271
  prerelease: false
272
272
  version_requirements: !ruby/object:Gem::Requirement
273
273
  requirements:
274
274
  - - "~>"
275
275
  - !ruby/object:Gem::Version
276
- version: 2.4.1
276
+ version: '2.13'
277
277
  - !ruby/object:Gem::Dependency
278
278
  name: rubocop-rspec
279
279
  requirement: !ruby/object:Gem::Requirement
280
280
  requirements:
281
281
  - - "~>"
282
282
  - !ruby/object:Gem::Version
283
- version: 1.37.0
283
+ version: '2.8'
284
284
  type: :development
285
285
  prerelease: false
286
286
  version_requirements: !ruby/object:Gem::Requirement
287
287
  requirements:
288
288
  - - "~>"
289
289
  - !ruby/object:Gem::Version
290
- version: 1.37.0
290
+ version: '2.8'
291
291
  - !ruby/object:Gem::Dependency
292
292
  name: simplecov
293
293
  requirement: !ruby/object:Gem::Requirement
@@ -302,8 +302,8 @@ dependencies:
302
302
  - - "~>"
303
303
  - !ruby/object:Gem::Version
304
304
  version: '0.15'
305
- description:
306
- email:
305
+ description:
306
+ email:
307
307
  executables: []
308
308
  extensions: []
309
309
  extra_rdoc_files: []
@@ -383,7 +383,7 @@ homepage: https://github.com/toptal/granite
383
383
  licenses:
384
384
  - MIT
385
385
  metadata: {}
386
- post_install_message:
386
+ post_install_message:
387
387
  rdoc_options: []
388
388
  require_paths:
389
389
  - lib
@@ -391,15 +391,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
391
391
  requirements:
392
392
  - - ">="
393
393
  - !ruby/object:Gem::Version
394
- version: '0'
394
+ version: '2.5'
395
395
  required_rubygems_version: !ruby/object:Gem::Requirement
396
396
  requirements:
397
397
  - - ">="
398
398
  - !ruby/object:Gem::Version
399
399
  version: '0'
400
400
  requirements: []
401
- rubygems_version: 3.2.29
402
- signing_key:
401
+ rubygems_version: 3.1.6
402
+ signing_key:
403
403
  specification_version: 4
404
404
  summary: Another business actions architecture for Rails apps
405
405
  test_files: []