object_attorney 1.0.0 → 1.0.1

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjJjNDYyNTk0NGVlMGRkNjdjMGNiZDFlOWE4NTE1NjZmZWUyMWQ4MA==
4
+ NTViOWU1YWYzNTQ4ZDhlNjU3N2U2Yjg5YTc3ZTk5ODliNTVlM2NlZA==
5
5
  data.tar.gz: !binary |-
6
- NGUzNDc3NDNiMmRjYTY0YTVkZTFjMDg4NDQ1NDAwMmFlZDRmYTZmYw==
7
- !binary "U0hBNTEy":
6
+ NWQ5MGY3MTlhZWU0ODU4YTNhMzY1NjBjMjdkOTM3YzM0ODBmNTViYQ==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- YTRjZjcxNWRmNDdlOThmMzE1YzYwY2UzMjc2NzAyMTIyZmQwMjk0MzVjYjlj
10
- OTE4NDEwZGIxMWFmMzZkZjNmNjU3YjM4ZWFkNGYzOTgyNDhhZWVjZWZiOTY1
11
- ODk1NTg5YWVhZmNhODRkYjRkNzhhODllZTdkNTU4MjhlYWJhMGM=
9
+ NjMyYjMyOTM3YmQyMzJkMDU4OTExMjNhMWExNmI1NzQ2MjRhYTkwMjAwN2Vj
10
+ ZTczNzliOTk3ZDdhYTAzOTBhNjc5NDYwNjRlNGRkMmY2NzdlMGM1NTE3YTZm
11
+ N2VkMWI0N2Q2ODM3NGJhYWE5NmQ4ZjA4ZTA5YjNhYWE0OGZhYzE=
12
12
  data.tar.gz: !binary |-
13
- NTllZmQyNDNiYjdhMjhjOWYyNmE1YWJlNjY1M2VhZmMxNWE5YTIxY2ExNmZj
14
- ZDk2NzAwNWI0MjY4NWFiYjdjZmE2YjJhMDYyOTBhMzcwYTJjNGI0NmI1YzRj
15
- OGM4MTcwYzU0YWU3ZTA3ZGY5YjYyZTBhMzExNDQzNWU3Y2Y5NTk=
13
+ NzNiZTUwYzg3ZTliZTQ4NWRlODEyMWUxZTIxNjFhODMxNWFmYmM5NmViYjQ0
14
+ NzZhMmVmOGJhNDFlMjcxOWFkMGM2YWZjNDlmYWUyOWYyY2Q3YmE2ZjllMmVj
15
+ ODA2MDM3NmMwYTMxMTFmNTE0YzM1MGViMzM0NzA2N2U5MjM4NTQ=
@@ -2,7 +2,7 @@ module ObjectAttorney
2
2
  module NestedObjects
3
3
 
4
4
  def nested_objects
5
- self.class.instance_variable_get("@nested_objects").map { |nested_object_sym| self.send(nested_object_sym) }.flatten
5
+ @@nested_objects.map { |nested_object_sym| self.send(nested_object_sym) }.flatten
6
6
  end
7
7
 
8
8
  def mark_for_destruction
@@ -31,7 +31,7 @@ module ObjectAttorney
31
31
  end
32
32
 
33
33
  def import_nested_objects_errors
34
- self.class.instance_variable_get("@nested_objects").map do |nested_object_sym|
34
+ @@nested_objects.map do |nested_object_sym|
35
35
 
36
36
  [*self.send(nested_object_sym)].each do |nested_object|
37
37
  nested_object.errors.full_messages.each { |message| self.errors.add(nested_object_sym, message) }
@@ -55,7 +55,7 @@ module ObjectAttorney
55
55
  validate :validate_nested_objects
56
56
  end
57
57
 
58
- base.instance_variable_set("@nested_objects", [])
58
+ @@nested_objects = []
59
59
  end
60
60
 
61
61
  def attributes_without_destroy(attributes)
@@ -1,3 +1,3 @@
1
1
  module ObjectAttorney
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -35,7 +35,7 @@ module ObjectAttorney
35
35
  respond_to?(attribute) ? send(attribute) : nil
36
36
  end
37
37
 
38
- protected #--------------------------------------------------protected
38
+ protected #################### PROTECTED METHODS DOWN BELOW ######################
39
39
 
40
40
  def allowed_attribute(attribute)
41
41
  attribute = attribute.to_s
@@ -88,17 +88,13 @@ module ObjectAttorney
88
88
  module ClassMethods
89
89
 
90
90
  def represents(represented_object, represented_object_class = nil)
91
- @represented_object_class = represented_object_class || represented_object.to_s.camelize.constantize
91
+ @@represented_object_class = represented_object_class || represented_object.to_s.camelize.constantize
92
92
 
93
93
  define_method(represented_object) do
94
- @represented_object ||= self.class.represented_object_class.new
94
+ @represented_object ||= @@represented_object_class.new
95
95
  end
96
96
  end
97
97
 
98
- def represented_object_class
99
- @represented_object_class
100
- end
101
-
102
98
  def delegate_properties(*properties, options)
103
99
  properties.each { |property| delegate_propertiy(property, options) }
104
100
  end
@@ -108,19 +104,19 @@ module ObjectAttorney
108
104
  end
109
105
 
110
106
  def attr_white_list=(*white_list)
111
- @white_list = white_list.map(&:to_s)
107
+ @@white_list = white_list.map(&:to_s)
112
108
  end
113
109
 
114
110
  def white_list
115
- @white_list ||= []
111
+ @@white_list ||= []
116
112
  end
117
113
 
118
114
  def attr_black_list(*black_list)
119
- @black_list = black_list.map(&:to_s)
115
+ @@black_list = black_list.map(&:to_s)
120
116
  end
121
117
 
122
118
  def black_list
123
- @black_list ||= ["_destroy"]
119
+ @@black_list ||= ["_destroy"]
124
120
  end
125
121
 
126
122
  def human_attribute_name(attribute_key_name, options = {})
@@ -142,7 +138,7 @@ module ObjectAttorney
142
138
  end
143
139
 
144
140
  def model_name
145
- @_model_name ||= begin
141
+ @@_model_name ||= begin
146
142
  namespace = self.parents.detect do |n|
147
143
  n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
148
144
  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: 1.0.0
4
+ version: 1.0.1
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: 2013-10-06 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.7
80
+ rubygems_version: 2.1.10
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: This gem allows you to extract the code responsible for Validations, Nested