Skip to content

Commit 653d1b8

Browse files
committed
chore: add frozen_string_literal comment and using new ruby syntax
1 parent 4a15cf9 commit 653d1b8

37 files changed

+83
-8
lines changed

Appraisals

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# ActiveModel integrations
24
appraise 'active_model_7.1' do
35
gem 'activemodel', '~> 7.1.0'

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in state_machine2_activemodel.gemspec

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'rake/testtask'
35

gemfiles/active_model_7.1.gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"
46

7+
gem "mutex_m"
58
gem "activemodel", "~> 7.1.0"
69

710
platforms :mri do

gemfiles/active_model_7.2.gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"
46

7+
gem "mutex_m"
58
gem "activemodel", "~> 7.2.0"
69

710
platforms :mri do

gemfiles/active_model_8.0.gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"
46

7+
gem "mutex_m"
58
gem "activemodel", "~> 8.0.0"
69

710
platforms :mri do

gemfiles/active_model_edge.gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source "https://rubygems.org"
46

7+
gem "mutex_m"
58
gem "activemodel", github: "rails/rails", branch: "main"
69

710
platforms :mri do

lib/state_machines-activemodel.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support'
24
require 'state_machines/integrations/active_model'
35

lib/state_machines/integrations/active_model.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
require 'active_model'
24
require 'active_support/core_ext/hash/keys'
3-
require 'active_support/core_ext/module/attribute_accessors.rb'
5+
require 'active_support/core_ext/module/attribute_accessors'
46
require 'state_machines'
57
require 'state_machines/integrations/base'
68
require 'state_machines/integrations/active_model/version'
@@ -83,7 +85,7 @@ module Integrations #:nodoc:
8385
# state_machine do
8486
# ...
8587
# state :first_gear, :second_gear do
86-
# validate {|vehicle| vehicle.speed_is_legal}
88+
# validate { |vehicle| vehicle.speed_is_legal }
8789
# end
8890
# end
8991
# end
@@ -292,7 +294,7 @@ module Integrations #:nodoc:
292294
# module StateMachine::Integrations::MyORM
293295
# include ActiveModel
294296
#
295-
# mattr_accessor(:defaults) { action: :persist }
297+
# mattr_accessor(:defaults) { { action: :persist } }
296298
#
297299
# def self.matches?(klass)
298300
# defined?(::MyORM::Base) && klass <= ::MyORM::Base
@@ -324,10 +326,7 @@ def self.matching_ancestors
324326
def invalidate(object, attribute, message, values = [])
325327
if supports_validations?
326328
attribute = self.attribute(attribute)
327-
options = values.reduce({}) do |h, (key, value)|
328-
h[key] = value
329-
h
330-
end
329+
options = values.to_h { |key, value| [key, value] }
331330

332331
default_options = default_error_message_options(object, attribute, message)
333332
object.errors.add(attribute, message, **options, **default_options)
@@ -337,7 +336,7 @@ def invalidate(object, attribute, message, values = [])
337336
# Describes the current validation errors on the given object. If none
338337
# are specific, then the default error is interpeted as a "halt".
339338
def errors_for(object)
340-
object.errors.empty? ? 'Transition halted' : object.errors.full_messages * ', '
339+
object.errors.empty? ? 'Transition halted' : object.errors.full_messages.join(', ')
341340
end
342341

343342
# Resets any errors previously added when invalidating the given object

lib/state_machines/integrations/active_model/locale.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
{ en: {
24
activemodel: {
35
errors: {

0 commit comments

Comments
 (0)