object_attorney 2.10.9 → 2.10.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTZjYmJlOTBjNzg4MWNmZTUxMTI2MzZjZGFkZmE4NTlhOTMxNjUyNg==
4
+ OWMyMWJkZmNhMjRjMDI1Y2YzMzYyYjA5MmZkMTRhOWZhNmE4MjVmOA==
5
5
  data.tar.gz: !binary |-
6
- YjdiNzA3MTlhMDMxYjZlNzM0NmFjMDMzMzdiYTMzNmRiZGYwZGFjZQ==
6
+ NmQ1OWI4OTExMDUxNzdmN2E0YWM1MTU1ZjBlNWNjYmI1M2IyOGUxYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDEyY2NmYTM0ODVkMjA2NDZkMWJhZWFiYTBmMjFmODVmNmIzZWQ0NDc3MGRm
10
- YjhkZWVmNjFhZTc5NGUxMThlNDI2Njg2NDRjODQ0MTA1ZDNlNmYzZmFmYTE0
11
- ZDc4NTUwN2M0YjI2ZGNjZWU1MGRhMTg4MjYyMzVkYmQzNDFlYTk=
9
+ YTE5MzczY2ZhMjM5N2Q4MzAxNTQwNjg4OWQxYmMwMjI1YTNjYTNhYmRlNGQy
10
+ MjBlODNiZTFkYmE4YmE5YzQ3MjgxZTAxYjRiNDUzYjlmMzkzYjcxMzY5OWVi
11
+ NDA2OGE3NzU4ODI2NTUyM2VmZDMxZTYzNTA3NzY2YmU0Zjg1NTA=
12
12
  data.tar.gz: !binary |-
13
- OTFkNjY0NmNkNzZmYzU4NjIwMGM1NDgxYTNiMjZlYzU0OTY2ZDU4MTM5OGRj
14
- NjNiZTU2NDI1OWMzN2MyMGFiNjAyODhmMDVkMzY0NTZmZGU0Yjg2MWMxYzA0
15
- MWUwM2UyYTBlNmNiOGVjMjc2ZTBhNzBlNGU4YmNkNTZhODEwYmE=
13
+ ODI1Y2RhZjM1NzA3NGE4MjlmYWIzMDA1YjY3YzQzMjdhNTE0YjUyMmY3MjVh
14
+ N2E0NmFkNjdjMTU0NDhmNWYyYTJiZDdkNGNmZTA2ZTdmMWMxZWQ4MjhlNjk1
15
+ YzJlYzgzOGYxNTU3NTg0MDVhMzNmMjc2NWViZWE4NWIyMTRjZDY=
data/console.rb CHANGED
@@ -14,4 +14,23 @@ p = PostWithCommentsAndAddressForm.new(address_attributes: address_attributes)
14
14
 
15
15
  a = AddressForm.new(post_attributes: { title: 'asd', body: 'body' })
16
16
 
17
+
18
+ params = {
19
+ post: {
20
+ title: 'First post',
21
+ body: 'post body',
22
+ comments_attributes: {
23
+ "0" => { body: "body1" },
24
+ "1" => { body: "body2" }
25
+ }
26
+ }
27
+ }
28
+
29
+ post_form = PostForm::Base.new(params[:post])
30
+ post_form.save
31
+
32
+
33
+ post_form = PostForm::Base.new(comments_attributes: { '1' => { id: 1, body: '1', _destroy: true } })
34
+
35
+
17
36
  binding.pry
@@ -10,10 +10,16 @@ module ObjectAttorney
10
10
  end
11
11
 
12
12
  def mark_for_destruction
13
+ represented_object.respond_to?(:mark_for_destruction) && represented_object.mark_for_destruction
14
+
13
15
  @marked_for_destruction = true
14
16
  end
15
17
 
16
18
  def marked_for_destruction?
19
+ if represented_object.respond_to?(:marked_for_destruction?) && represented_object.marked_for_destruction?
20
+ @marked_for_destruction = true
21
+ end
22
+
17
23
  @marked_for_destruction
18
24
  end
19
25
 
@@ -1,3 +1,3 @@
1
1
  module ObjectAttorney
2
- VERSION = "2.10.9"
2
+ VERSION = "2.10.10"
3
3
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe AddressForm do
4
4
 
5
- it "FormObject with a belongs_to with a differente class then the represented_object's relation" do
5
+ it "FormObject with a belongs_to with a different class then the represented_object's relation" do
6
6
  params = {
7
7
  address: {
8
8
  post_attributes: { title: 'asd', body: 'body' }
@@ -16,4 +16,30 @@ describe AddressForm do
16
16
  address_form.address.post.should_not == nil
17
17
  end
18
18
 
19
+ it "FormObject receiving a _destroy attribute, should mark the relevant represented_object, for destruction too" do
20
+ Post.create(title: 'title', body: 'body')
21
+
22
+ address = Address.create(street: 'street', city: 'city', post_id: 1)
23
+
24
+ params = {
25
+ address: {
26
+ post_attributes: { id: 1, _destroy: true }
27
+ }
28
+ }
29
+
30
+ address_form = AddressForm.new(params[:address], address)
31
+
32
+ address_form.post.marked_for_destruction?.should == true
33
+ address_form.address.post.marked_for_destruction?.should == true
34
+ end
35
+
36
+ it "FormObject initialized with a marked_for_destruction object, should reflect that" do
37
+ address = Address.create(street: 'street', city: 'city')
38
+ address.mark_for_destruction
39
+
40
+ address_form = AddressForm.new({}, address)
41
+
42
+ address_form.marked_for_destruction?.should == true
43
+ end
44
+
19
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_attorney
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.9
4
+ version: 2.10.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2014-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler