has_state_machine 0.4.1 → 0.6.0

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: 58bd21a655ff20122628fbc9707b04d77be5a318753cabb721c16073ad9d7edb
4
- data.tar.gz: ee6c83c9b070867c9715b9dc3970597f9c5db61ae616839f2bd3841bd397b501
3
+ metadata.gz: 9f5dce90790fc426f0030f3052f7a09aecc373c5cf71185e4d7a2b22280e834d
4
+ data.tar.gz: e41c13e77237380c39f420797f2f151a3e615390c3966ac196432f1805370357
5
5
  SHA512:
6
- metadata.gz: ce2c67a3440e3175693e589188456434ac593c3f219abcdb9607f7f2241a00e51746764c5b17623c66259f9bc6fdb3e1de8547262da27c93d16adefdf090b130
7
- data.tar.gz: da2d558bc3dbd3686ce46538bd426956c5664a3f608350007643ae53626eae944f95c5d6180ca42b39459006bbd4084faf7b58d1a6354d262119d64718f16eac
6
+ metadata.gz: 78b889ab38cc3aa0bbf1c7c6f43918894a4afab27be0a4c70ac223b58d8d71521154988ba23c4596110c760295dacdc87005fe67b9709edb894c5c7c64f822ba
7
+ data.tar.gz: 2e5b88c5c7866ce435593a05d9117fe69839e3f01cba591744466ac91cbcb6e26ac700bea31282e3a6c12d04db3c6ab025a7b2a8bf62ced6f91e96ae17babd05
@@ -51,7 +51,7 @@ module HasStateMachine
51
51
  # Defines the namespace of the models possible states.
52
52
  # Can be overwritten to use a different namespace.
53
53
  define_singleton_method :workflow_namespace do
54
- (options[:workflow_namespace] || "Workflow::#{self}")
54
+ options[:workflow_namespace] || "Workflow::#{self}"
55
55
  end
56
56
 
57
57
  ##
@@ -33,7 +33,7 @@ module HasStateMachine
33
33
  def initialize(object)
34
34
  @object = object
35
35
 
36
- super state
36
+ super(state)
37
37
  end
38
38
 
39
39
  ##
@@ -83,6 +83,8 @@ module HasStateMachine
83
83
  rollback_transition unless object.update("#{object.state_attribute}": state)
84
84
  end
85
85
  end
86
+
87
+ object.reload.public_send(object.state_attribute) == state
86
88
  end
87
89
 
88
90
  private
@@ -67,7 +67,7 @@ module HasStateMachine
67
67
  # @example Check if a post is published
68
68
  # > post.published?
69
69
  # #=> true
70
- define_method "#{state}?" do
70
+ define_method :"#{state}?" do
71
71
  current_state == state
72
72
  end
73
73
  end
@@ -78,7 +78,7 @@ module HasStateMachine
78
78
  # Getter for the current state of the model based on the configured state
79
79
  # attribute.
80
80
  def current_state
81
- attributes.with_indifferent_access[state_attribute]
81
+ self[state_attribute]
82
82
  end
83
83
 
84
84
  ##
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasStateMachine
4
- VERSION = "0.4.1"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_state_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Hargett
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-02 00:00:00.000000000 Z
12
+ date: 2024-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -29,16 +29,16 @@ dependencies:
29
29
  name: sqlite3
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.4'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '1.4'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pry
44
44
  requirement: !ruby/object:Gem::Requirement