From 85a0b97449902a56d3ffc9c5ece0eadbcec2b504 Mon Sep 17 00:00:00 2001 From: Florian Frank <flori@ping.de> Date: Fri, 28 Sep 2012 12:53:23 +0200 Subject: [PATCH] Use Ruby attribute setters and not write_attribute This change will call the writer methods defined on an AR model, if they're implemented, instead of going behind their back. This also avoids a rails 3 deprecation warning, if the named attributes aren't actually database attributes. --- lib/geocoder/stores/active_record.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/geocoder/stores/active_record.rb b/lib/geocoder/stores/active_record.rb index 34a52a78..ea1bd2ad 100644 --- a/lib/geocoder/stores/active_record.rb +++ b/lib/geocoder/stores/active_record.rb @@ -289,8 +289,8 @@ module Geocoder::Store do_lookup(false) do |o,rs| if r = rs.first unless r.latitude.nil? or r.longitude.nil? - o.send :write_attribute, self.class.geocoder_options[:latitude], r.latitude - o.send :write_attribute, self.class.geocoder_options[:longitude], r.longitude + o.__send__ "#{self.class.geocoder_options[:latitude]}=", r.latitude + o.__send__ "#{self.class.geocoder_options[:longitude]}=", r.longitude end r.coordinates end @@ -307,7 +307,7 @@ module Geocoder::Store do_lookup(true) do |o,rs| if r = rs.first unless r.address.nil? - o.send :write_attribute, self.class.geocoder_options[:fetched_address], r.address + o.__send__ "#{self.class.geocoder_options[:fetched_address]}=", r.address end r.address end -- GitLab