state_machines-activerecord 0.5.1 → 0.5.2

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: e3b0f15bfdc4b116addd104136821751286e8f8452f5513141cd633560e6e004
4
- data.tar.gz: 76a1a6abed537af626d8a312cb7e2cb382d1b360a04111179c3808dacc940cf5
3
+ metadata.gz: 11815a499f4deef7d5f2c64ab0bbb7fd4b18a17110c0f4fa33a607bd764928e5
4
+ data.tar.gz: 4c5de06c1603fee79e66b2efd2549946f9e047f1bf1c772859c281d16379bf57
5
5
  SHA512:
6
- metadata.gz: 439cfcd6eadd8abbaf6dd7de97ec584bf582465f1f2ff0dce0988c2b6c73af81a664f185a0b46c38cf7a8184d1365836d07ed3bc04acd117a78fb6b3ac372540
7
- data.tar.gz: f37e758e101e747a8e135eea316316271ef5881eb3bff6606e17ceaa3ddf05ad09dc23d96dda2fd3aa22d5ea6fca9be224b19a07e2e0331677b3b9e9208007f9
6
+ metadata.gz: c325ff584ecf667665c5b94b9769b449a01e80a45f7d8045e05351167381d62251d01ccff4686a5e2429b6776ffb692dbf97cf885aa74c1a72c117d71579fe52
7
+ data.tar.gz: d648a81589482a9076d33fab2d9b3eed8bf0a36bb3f30daaee12634cf7d7f87ed7e8a85f7f3424eadc4676fccfd333f33fd1bdd4e9ec4b91651f4f8b6a8cbb50
data/README.md CHANGED
@@ -6,10 +6,6 @@
6
6
  The Active Record 4.1+ integration adds support for database transactions, automatically
7
7
  saving the record, named scopes, validation errors.
8
8
 
9
- ## Dependencies
10
-
11
- Active Record 4.1+
12
-
13
9
  ## Installation
14
10
 
15
11
  Add this line to your application's Gemfile:
@@ -26,6 +22,10 @@ Or install it yourself as:
26
22
 
27
23
  ## Usage
28
24
 
25
+ For the complete usage guide, see http://www.rubydoc.info/github/state-machines/state_machines-activerecord/StateMachines/Integrations/ActiveRecord
26
+
27
+ ### Example
28
+
29
29
  ```ruby
30
30
  class Vehicle < ActiveRecord::Base
31
31
  state_machine :initial => :parked do
@@ -460,7 +460,9 @@ module StateMachines
460
460
  define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
461
461
  def initialize(attributes = nil)
462
462
  super(attributes) do |*args|
463
- self.class.state_machines.initialize_states(self, {}, attributes || {})
463
+ scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
464
+
465
+ self.class.state_machines.initialize_states(self, {}, scoped_attributes)
464
466
  yield(*args) if block_given?
465
467
  end
466
468
  end
@@ -468,8 +470,10 @@ module StateMachines
468
470
  elsif ::ActiveRecord.gem_version >= Gem::Version.new('4.2')
469
471
  define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
470
472
  def initialize(attributes = nil, options = {})
473
+ scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
474
+
471
475
  super(attributes, options) do |*args|
472
- self.class.state_machines.initialize_states(self, {}, attributes || {})
476
+ self.class.state_machines.initialize_states(self, {}, scoped_attributes)
473
477
  yield(*args) if block_given?
474
478
  end
475
479
  end
@@ -492,8 +496,10 @@ module StateMachines
492
496
  # Initializes dynamic states
493
497
  define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
494
498
  def initialize(attributes = nil, options = {})
499
+ scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
500
+
495
501
  super(attributes, options) do |*args|
496
- self.class.state_machines.initialize_states(self, {}, attributes || {})
502
+ self.class.state_machines.initialize_states(self, {}, scoped_attributes)
497
503
  yield(*args) if block_given?
498
504
  end
499
505
  end
@@ -1,7 +1,7 @@
1
1
  module StateMachines
2
2
  module Integrations
3
3
  module ActiveRecord
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.2'
5
5
  end
6
6
  end
7
7
  end
@@ -27,6 +27,12 @@ class MachineWithInitializedStateTest < BaseTestCase
27
27
  assert_equal 'idling', record.state
28
28
  end
29
29
 
30
+ def test_should_allow_different_initial_state_when_using_create_with
31
+ record = @model.create_with(state: 'idling').new
32
+
33
+ assert_equal 'idling', record.state
34
+ end
35
+
30
36
  def test_should_allow_different_initial_state_when_dynamic
31
37
  @machine.initial_state = lambda { :parked }
32
38
  record = @model.new(:state => 'idling')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machines-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-19 00:00:00.000000000 Z
12
+ date: 2018-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machines-activemodel
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.7.3
217
+ rubygems_version: 2.7.6
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: State machines Active Record Integration