Permalink
Browse files

Change after_initialize to after_find.

  • Loading branch information...
1 parent 504c0d7 commit 2d7da61bc51e7c31665344dc1d059bc8dc7e2159 Ronni Rasmussen committed Mar 21, 2012
Showing with 4 additions and 4 deletions.
  1. +3 −3 lib/measurement.rb
  2. +1 −1 measurement.gemspec
View
6 lib/measurement.rb
@@ -6,8 +6,8 @@ def self.included(base)
def measurement_convert(name, from, to)
from = from.call if from.is_a?(Proc)
to = to.call if to.is_a?(Proc)
-
- self[name] = self[name].from(from).to(to).to_f.round(3) if !self[name].nil? && from != to
+
+ self[name] = self[name].from(from).to(to).to_f.round(3) if from != to
end
module ClassMethods
@@ -24,7 +24,7 @@ def measurement(*args, &block)
measurement_convert(name, options[:database_unit], options[:model_unit])
end
- after_initialize do |record|
+ after_find do |record|
measurement_convert(name, options[:database_unit], options[:model_unit])
end
end
View
2 measurement.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Ronni Steen Rasmussen"]
- s.date = "2012-03-13"
+ s.date = "2012-03-21"
s.description = "Automaticly convert measurements units."
s.email = "ronni.rasmussen@gmail.com"
s.extra_rdoc_files = ["README.md", "lib/measurement.rb"]

0 comments on commit 2d7da61

Please sign in to comment.