activerecord 5.0.0.beta1 → 5.0.0.beta1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e133ed5dfb51d14f02b6c9500a2d6ef12ff3e44
4
- data.tar.gz: f2c8ed50961369f794784c36333255503f35fee9
3
+ metadata.gz: ccbf826c049cab6dd670fb772aac6970dfa7b61d
4
+ data.tar.gz: a80f795385b7acaaf8350dd3e2268da4a6c32d1f
5
5
  SHA512:
6
- metadata.gz: 7564870b045ef432c7e34f3633ae3dce0e555727226453144cda406999f0061d5ba663cac60c4b53f390228c33a785ea47a9bda9511e5d699a1cbce61892cb8e
7
- data.tar.gz: 71237455c5267cb825c34ea0a450e79efa57a757ffc90a2bff1c5965ab9bbef668f323ebbbc4f51ec8a354fac9dff3a13076a49791069ad0410a57f3a7c2f194
6
+ metadata.gz: 4a01fab31f456f7d17652a97e6b2b101dfe450a0cedf76e6f4086f8faef3ada11267cffdc68c71c83d9edaffae792010b2a7b4a831e8508c76f46e6751fbb875
7
+ data.tar.gz: 4099fc5636e010f802b4294987bc73b66f6975485e435f30566a810541b9778ef677914d7969b9c7dbefd861262d008f6ed6390d98c5c7b08480788f52ea17b0
@@ -95,7 +95,7 @@ module ActiveRecord
95
95
 
96
96
  module Enum
97
97
  def self.extended(base) # :nodoc:
98
- base.class_attribute(:defined_enums)
98
+ base.class_attribute(:defined_enums, instance_writer: false)
99
99
  base.defined_enums = {}
100
100
  end
101
101
 
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta1"
11
+ PRE = "beta1.1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -542,7 +542,7 @@ module ActiveRecord
542
542
  # has_destroy_flag? or if a <tt>:reject_if</tt> proc exists for this
543
543
  # association and evaluates to +true+.
544
544
  def reject_new_record?(association_name, attributes)
545
- has_destroy_flag?(attributes) || call_reject_if(association_name, attributes)
545
+ will_be_destroyed?(association_name, attributes) || call_reject_if(association_name, attributes)
546
546
  end
547
547
 
548
548
  # Determines if a record with the particular +attributes+ should be
@@ -551,7 +551,8 @@ module ActiveRecord
551
551
  #
552
552
  # Returns false if there is a +destroy_flag+ on the attributes.
553
553
  def call_reject_if(association_name, attributes)
554
- return false if has_destroy_flag?(attributes)
554
+ return false if will_be_destroyed?(association_name, attributes)
555
+
555
556
  case callback = self.nested_attributes_options[association_name][:reject_if]
556
557
  when Symbol
557
558
  method(callback).arity == 0 ? send(callback) : send(callback, attributes)
@@ -560,6 +561,15 @@ module ActiveRecord
560
561
  end
561
562
  end
562
563
 
564
+ # Only take into account the destroy flag if <tt>:allow_destroy</tt> is true
565
+ def will_be_destroyed?(association_name, attributes)
566
+ allow_destroy?(association_name) && has_destroy_flag?(attributes)
567
+ end
568
+
569
+ def allow_destroy?(association_name)
570
+ self.nested_attributes_options[association_name][:allow_destroy]
571
+ end
572
+
563
573
  def raise_nested_attributes_record_not_found!(association_name, record_id)
564
574
  model = self.class._reflect_on_association(association_name).klass.name
565
575
  raise RecordNotFound.new("Couldn't find #{model} with ID=#{record_id} for #{self.class.name} with ID=#{id}",
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  included do
10
- class_attribute :_reflections
11
- class_attribute :aggregate_reflections
10
+ class_attribute :_reflections, instance_writer: false
11
+ class_attribute :aggregate_reflections, instance_writer: false
12
12
  self._reflections = {}
13
13
  self.aggregate_reflections = {}
14
14
  end
@@ -6,7 +6,7 @@ module ActiveRecord
6
6
  included do
7
7
  # Stores the default scope for the class.
8
8
  class_attribute :default_scopes, instance_writer: false, instance_predicate: false
9
- class_attribute :default_scope_override, instance_predicate: false
9
+ class_attribute :default_scope_override, instance_writer: false, instance_predicate: false
10
10
 
11
11
  self.default_scopes = []
12
12
  self.default_scope_override = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta1
4
+ version: 5.0.0.beta1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta1
19
+ version: 5.0.0.beta1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0.beta1
26
+ version: 5.0.0.beta1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 5.0.0.beta1
33
+ version: 5.0.0.beta1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 5.0.0.beta1
40
+ version: 5.0.0.beta1.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -322,4 +322,3 @@ signing_key:
322
322
  specification_version: 4
323
323
  summary: Object-relational mapper framework (part of Rails).
324
324
  test_files: []
325
- has_rdoc: