activeentity 0.0.1.beta13 → 0.0.1.beta14

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: 105f988db4e8fa1f139198e4ae81a47a68c0bc8790d48fda2e85d3b136292cf8
4
- data.tar.gz: 18e30d59333b965a455843d58d423d64ec10b40464506d5672ce290b968ae282
3
+ metadata.gz: e54d10db138ce5521aa1ab4fde237c75a7aa3e865973ed5a3ec48a55fbff0e7d
4
+ data.tar.gz: 2604112ec917bddac683e8416787810075a7df1365903d2e36b40b5bc03e9256
5
5
  SHA512:
6
- metadata.gz: fb51b5353013d8ae282601c4027823cd4155c87a6b4969c78cd7a70964932fa8bcce04fc60f3756454c2e040243af0206e9e6a20046a682dc52b894e7ac3f11d
7
- data.tar.gz: b9aecb1a118fb2ae93a200793c246715744f40df5053cf62fe2e88ac17c202ce4c67ad54e4c3adc51b69a144e20df4bea5339afbdfc9b12d19291325e7be74f0
6
+ metadata.gz: 81bb5e2f93bba71814227e5076368816c7b2eb615b1f81c890330b1653f637d8a7a4a9d43533d726b3cafc2a603a1e61c2d29f352c1d64695d02f637559f56c5
7
+ data.tar.gz: 6624cf0afcdd210b7ae461b67ecb23c7d39332faa61a1c4d23d530c074660aefcb6e209772c4c0c715d772fa7b466dc30d6f0fd8c715f4f6a91b15d040cc4de8
@@ -10,7 +10,7 @@ module ActiveEntity
10
10
  MAJOR = 0
11
11
  MINOR = 0
12
12
  TINY = 1
13
- PRE = "beta13"
13
+ PRE = "beta14"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -402,33 +402,23 @@ module ActiveEntity
402
402
  # update_only is true, and a <tt>:_destroy</tt> key set to a truthy value,
403
403
  # then the existing record will be marked for destruction.
404
404
  def assign_nested_attributes_for_one_to_one_association(association_name, attributes)
405
- options = nested_attributes_options[association_name]
406
405
  if attributes.respond_to?(:permitted?)
407
406
  attributes = attributes.to_h
408
407
  end
409
408
  attributes = attributes.with_indifferent_access
410
409
  existing_record = send(association_name)
411
410
 
412
- if (options[:update_only] || !attributes["id"].blank?) && existing_record &&
413
- (options[:update_only] || existing_record.id.to_s == attributes["id"].to_s)
414
- assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy]) unless call_reject_if(association_name, attributes)
415
-
416
- elsif attributes["id"].present?
417
- raise_nested_attributes_record_not_found!(association_name, attributes["id"])
418
-
419
- elsif !reject_new_record?(association_name, attributes)
420
- assignable_attributes = attributes.except(*UNASSIGNABLE_KEYS)
411
+ assignable_attributes = attributes.except(*UNASSIGNABLE_KEYS)
421
412
 
422
- if existing_record && existing_record.new_record?
423
- existing_record.assign_attributes(assignable_attributes)
424
- association(association_name).initialize_attributes(existing_record)
413
+ if existing_record
414
+ existing_record.assign_attributes(assignable_attributes)
415
+ association(association_name).initialize_attributes(existing_record)
416
+ else
417
+ method = :"build_#{association_name}"
418
+ if respond_to?(method)
419
+ send(method, assignable_attributes)
425
420
  else
426
- method = :"build_#{association_name}"
427
- if respond_to?(method)
428
- send(method, assignable_attributes)
429
- else
430
- raise ArgumentError, "Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?"
431
- end
421
+ raise ArgumentError, "Cannot build association `#{association_name}'. Are you trying to build a polymorphic one-to-one association?"
432
422
  end
433
423
  end
434
424
  end
@@ -475,43 +465,22 @@ module ActiveEntity
475
465
  if attributes_collection.is_a? Hash
476
466
  keys = attributes_collection.keys
477
467
  attributes_collection = if keys.include?("id") || keys.include?(:id)
478
- [attributes_collection]
479
- else
480
- attributes_collection.values
481
- end
468
+ [attributes_collection]
469
+ else
470
+ attributes_collection.values
471
+ end
482
472
  end
483
473
 
484
474
  association = association(association_name)
485
475
 
486
- existing_records = association.target
476
+ association.target.clear
487
477
 
488
478
  attributes_collection.each do |attributes|
489
479
  if attributes.respond_to?(:permitted?)
490
480
  attributes = attributes.to_h
491
481
  end
492
482
  attributes = attributes.with_indifferent_access
493
-
494
- if attributes["id"].blank?
495
- unless reject_new_record?(association_name, attributes)
496
- association.reader.build(attributes.except(*UNASSIGNABLE_KEYS))
497
- end
498
- elsif existing_record = existing_records.detect { |record| record.id.to_s == attributes["id"].to_s }
499
- unless call_reject_if(association_name, attributes)
500
- # Make sure we are operating on the actual object which is in the association's
501
- # proxy_target array (either by finding it, or adding it if not found)
502
- # Take into account that the proxy_target may have changed due to callbacks
503
- target_record = association.target.detect { |record| record.id.to_s == attributes["id"].to_s }
504
- if target_record
505
- existing_record = target_record
506
- else
507
- association.add_to_target(existing_record, :skip_callbacks)
508
- end
509
-
510
- assign_to_or_mark_for_destruction(existing_record, attributes, options[:allow_destroy])
511
- end
512
- else
513
- raise_nested_attributes_record_not_found!(association_name, attributes["id"])
514
- end
483
+ association.reader.build(attributes.except(*UNASSIGNABLE_KEYS))
515
484
  end
516
485
  end
517
486
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeentity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta13
4
+ version: 0.0.1.beta14
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-10 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport