duck_record 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea74dd5ae7d2fa4b29957220898223bffacd1e11
4
- data.tar.gz: b6b5baee57bc4bd3915172b22b84a2fb948a236b
3
+ metadata.gz: 06bf2457884cf16768ed22c8eab54c06cd03e59d
4
+ data.tar.gz: 2b9fdb3b1e20e91e52e2e553f061302f777d2885
5
5
  SHA512:
6
- metadata.gz: a36210ba1a1fff6aae044d453641b0db60a9f93b80e24a261c012b2bec8f6afdc57a80def009289a8711f0463d7ec9ad6c9238aff7c71ad8157ea4e3fafc74e3
7
- data.tar.gz: 7a04f4c5824149560e3d0784781b2535a05438d090c3e397ff324ebc9a2e1911424c6a22342318f09f50e9faf6c43e22c40a11f05553d3adbe38c0189a073215
6
+ metadata.gz: 42bfba1df7380612fa22a300225f8e75e46e14bccc565c7c1e403105d7b6bba293376e32e08a6a74fd7c47a21120c5a86ef836eabde8a23bac818eb7b80817b1
7
+ data.tar.gz: '095d81f5ac4b851f3989f6bba870e0dd30cbf2c4542968183dc4e963fcc6a2162deb0956519ff9b9f1205acad6baa5fcb61f9de42db9de4f23d9935ead1ac449'
@@ -294,6 +294,10 @@ module DuckRecord #:nodoc:
294
294
  def persisted?
295
295
  false
296
296
  end
297
+
298
+ def new_record?
299
+ true
300
+ end
297
301
  end
298
302
 
299
303
  ActiveSupport.run_load_hooks(:duck_record, Base)
@@ -363,6 +363,31 @@ module DuckRecord
363
363
  end
364
364
  end
365
365
 
366
+ # Marks this record to be destroyed as part of the parent's save transaction.
367
+ # This does _not_ actually destroy the record instantly, rather child record will be destroyed
368
+ # when <tt>parent.save</tt> is called.
369
+ #
370
+ # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model.
371
+ def mark_for_destruction
372
+ @marked_for_destruction = true
373
+ end
374
+
375
+ # Returns whether or not this record will be destroyed as part of the parent's save transaction.
376
+ #
377
+ # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model.
378
+ def marked_for_destruction?
379
+ @marked_for_destruction
380
+ end
381
+
382
+ # Returns ActiveRecord::AutosaveAssociation::marked_for_destruction? It's
383
+ # used in conjunction with fields_for to build a form element for the
384
+ # destruction of this association.
385
+ #
386
+ # See ActionView::Helpers::FormHelper::fields_for for more info.
387
+ def _destroy
388
+ marked_for_destruction?
389
+ end
390
+
366
391
  private
367
392
 
368
393
  # Attribute hash keys that should not be assigned as normal attributes.
@@ -447,7 +472,7 @@ module DuckRecord
447
472
  check_record_limit!(options[:limit], attributes_collection)
448
473
 
449
474
  if attributes_collection.is_a? Hash
450
- attributes_collection = [attributes_collection]
475
+ attributes_collection = attributes_collection.values
451
476
  end
452
477
 
453
478
  association = association(association_name)
@@ -1,3 +1,3 @@
1
1
  module DuckRecord
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport