Skip to content

Commit

Permalink
perf: Remove attributes invocation (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhurd2326 authored Jul 19, 2024
1 parent 7a20ea3 commit f6d785d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['2.7', '3.0']
ruby: ['3.0']
steps:
- name: Checkout
uses: actions/checkout@master
Expand All @@ -27,11 +27,6 @@ jobs:
- name: Lint
run: bundle exec rake lint

- name: Test against rails main
run: |
bundle exec appraisal rails-main bundle install
bundle exec appraisal rails-main rake test
- name: Test against rails 7.0
run: |
bundle exec appraisal rails-7-0 bundle install
Expand Down
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.7)
minitest (5.17.0)
net-imap (0.3.4)
date
Expand All @@ -109,7 +110,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.14.2-arm64-darwin)
nokogiri (1.14.2)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.19.2)
parser (2.7.1.4)
Expand Down Expand Up @@ -189,7 +191,7 @@ DEPENDENCIES
has_state_machine!
pry
pry-rails
sqlite3
sqlite3 (~> 1.4)
standard

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion has_state_machine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "rails", ">= 5.2"

spec.add_development_dependency "sqlite3"
spec.add_development_dependency "sqlite3", "~> 1.4"
spec.add_development_dependency "pry"
spec.add_development_dependency "pry-rails"
spec.add_development_dependency "standard"
Expand Down
2 changes: 1 addition & 1 deletion lib/has_state_machine/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def define_helper_methods(states:, options:)
# Defines the namespace of the models possible states.
# Can be overwritten to use a different namespace.
define_singleton_method :workflow_namespace do
(options[:workflow_namespace] || "Workflow::#{self}")
options[:workflow_namespace] || "Workflow::#{self}"
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/has_state_machine/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class State < String
def initialize(object)
@object = object

super state
super(state)
end

##
Expand Down
4 changes: 2 additions & 2 deletions lib/has_state_machine/state_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module StateHelpers
# @example Check if a post is published
# > post.published?
# #=> true
define_method "#{state}?" do
define_method :"#{state}?" do
current_state == state
end
end
Expand All @@ -78,7 +78,7 @@ module StateHelpers
# Getter for the current state of the model based on the configured state
# attribute.
def current_state
attributes.with_indifferent_access[state_attribute]
self[state_attribute]
end

##
Expand Down

0 comments on commit f6d785d

Please sign in to comment.