smooth_operator 1.2.7 → 1.2.8

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
- YTM5NDgwNzg0NmI2ZTkwNTg5Y2RlMGI2NDY0ZDdjMzhiNjE2NTRhYw==
4
+ N2UwNzVjODExYjU5ZDViZjZhNmQwYmNlMGU5NjkxOGQ5N2U3YWFhYw==
5
5
  data.tar.gz: !binary |-
6
- MWJkNmU3ZjRjMGRkYjA2M2QyMWQzMGNhMWMwODFlYWIyNjYxNTgzYg==
6
+ ZjgwNjE3MGYzMTQ5NWVkYzkzZjU1MWRjMmJmNjFjYjkwMmYxN2JiNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWIxMWJhYWJiY2U1ZjM5YzBhOTVhMzUwZjNjODYzYzMxZWVhODQ2YzNjNDdj
10
- OGNkM2MzYTNlYTUyODhhNTlhYzBjOTcwMDhiZTNlYjk3MzJjZjkzZWNlN2U5
11
- YjZhMzhmZjM3NzYxN2E2NjI2NWUyMjhlNzI5NTBjNDZlODFmZmU=
9
+ ZThlZTRkMTMzMDcyMmE1MzU3ZDJkYzkxMzE2ZDU1NDUxZDc0NzFiN2M2ZmI3
10
+ ZDRjYjk0MWU1OGFhMWQ0MzllZWRlODM2YTczYTYyZGJmYzU3MmZkZTM1MWEx
11
+ ZGM5ZTAxNGJhOWVlM2QyMzM1NTI4N2Q0MjBkOThhYjA0MGM2NjY=
12
12
  data.tar.gz: !binary |-
13
- MGMyNmQ4ZTc1ZGVhMzAxNjE2M2E0ZmYyODMwZGY3YjQzMGVkMmI5MDVmZTMy
14
- NDAyYjlhZDZhNTM4MDFlNDkxMWU5ODMzZTkzODBmODVjZWZlYmZhOWJhNGE1
15
- MDViZjNiMjk0MjNmNTNjM2MwYjVlODI1MDg0ZTYyNmU2NDRhMzY=
13
+ ZGJhZmMwZWJmOTVlMGIzMzgzMmE4NTAyN2Y4MzYyZTk4NmY4YjA0ZDQ3OTRj
14
+ OGY0NDZjYmJjNDE1ZGNhYzhhMGJjMmVkZDk4Nzc0MTUwMGEyNTVlZjhkODIz
15
+ OWQyN2U4NmExOGYxYjJjNGM0NWExZDI1ODFlMDA2YTEyOTIxNDg=
@@ -16,14 +16,26 @@ module SmoothOperator
16
16
  object.class.reflect_on_association(association).klass.new(attributes)
17
17
  end
18
18
 
19
- alias :build :new
19
+ def build(attributes = {})
20
+ new_array, new_array_entry = get_array, new(attributes)
21
+
22
+ new_array.push new_array_entry
23
+
24
+ object.send("#{association}=", new_array)
25
+
26
+ new_array_entry
27
+ end
20
28
 
21
29
  protected ############### PROTECTED ###############
22
30
 
23
- def refresh
31
+ def get_array
24
32
  data = object.get_internal_data(association.to_s)
25
33
 
26
- __setobj__(data.nil? ? [] : [*data])
34
+ data.nil? ? [] : [*data]
35
+ end
36
+
37
+ def refresh
38
+ __setobj__ get_array
27
39
  end
28
40
 
29
41
  end
@@ -56,6 +56,10 @@ module SmoothOperator
56
56
  macro == :belongs_to
57
57
  end
58
58
 
59
+ def collection?
60
+ has_many?
61
+ end
62
+
59
63
  private ################################# private
60
64
 
61
65
  def macro_default(association)
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = "1.2.7"
2
+ VERSION = "1.2.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves