platanus 0.1.4 → 0.1.5

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.
@@ -157,38 +157,38 @@ module Platanus
157
157
  if _options.delete(:mirroring)
158
158
  stacked_model.accessible_attributes.each do |attr_name|
159
159
 
160
- unless self.method_defined? "#{attr_name}="
161
- send :define_method, "#{attr_name}=" do |value|
162
- mirror = instance_variable_get(mirror_cache_var)
163
- mirror = instance_variable_set(mirror_cache_var, {}) if mirror.nil?
164
- mirror[attr_name] = value
165
- end
166
- else
167
- Rails.logger.warn "stacked: failed to mirror setter for #{attr_name} in #{self.to_s}"
160
+ if self.method_defined? "#{attr_name}="
161
+ Rails.logger.warn "stacked: overriding setter for #{attr_name} in #{self.to_s}"
168
162
  end
169
163
 
170
- unless self.method_defined? attr_name
171
- send :define_method, attr_name do
172
- mirror = instance_variable_get(mirror_cache_var)
173
- return mirror[attr_name] if !mirror.nil? and mirror.has_key? attr_name
164
+ if self.method_defined? attr_name
165
+ Rails.logger.warn "stacked: overriding getter for #{attr_name} in #{self.to_s}"
166
+ end
174
167
 
175
- return self.send(prefix + attr_name) if self.respond_to? prefix + attr_name # return cached value if avaliable
176
- top = self.send top_value_prop
177
- return nil if top.nil?
178
- return top.send attr_name
179
- end
168
+ send :define_method, "#{attr_name}=" do |value|
169
+ mirror = instance_variable_get(mirror_cache_var)
170
+ mirror = instance_variable_set(mirror_cache_var, {}) if mirror.nil?
171
+ mirror[attr_name] = value
172
+ end
180
173
 
181
- send :define_method, "#{attr_name}_changed?" do
182
- mirror = instance_variable_get(mirror_cache_var)
183
- return true if !mirror.nil? and mirror.has_key? attr_name
184
- return self.send(prefix + attr_name + '_changed?') if self.respond_to? prefix + attr_name + '_changed?' # return cached value if avaliable
185
- return true # for now just return true for non cached attributes
186
- end
174
+ send :define_method, attr_name do
175
+ mirror = instance_variable_get(mirror_cache_var)
176
+ return mirror[attr_name] if !mirror.nil? and mirror.has_key? attr_name
187
177
 
188
- attr_accessible attr_name
189
- else
190
- Rails.logger.warn "stacked: failed to mirror getter for #{attr_name} in #{self.to_s}"
178
+ return self.send(prefix + attr_name) if self.respond_to? prefix + attr_name # return cached value if avaliable
179
+ top = self.send top_value_prop
180
+ return nil if top.nil?
181
+ return top.send attr_name
191
182
  end
183
+
184
+ send :define_method, "#{attr_name}_changed?" do
185
+ mirror = instance_variable_get(mirror_cache_var)
186
+ return true if !mirror.nil? and mirror.has_key? attr_name
187
+ return self.send(prefix + attr_name + '_changed?') if self.respond_to? prefix + attr_name + '_changed?' # return cached value if avaliable
188
+ return true # for now just return true for non cached attributes
189
+ end
190
+
191
+ attr_accessible attr_name
192
192
  end
193
193
 
194
194
  # before saving model, load changes from virtual attributes.
@@ -1,3 +1,3 @@
1
1
  module Platanus
2
- VERSION = "0.1.4" # 0.2 will come with tests!
2
+ VERSION = "0.1.5" # 0.2 will come with tests!
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-03 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json