Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change after_initialize to after_find.

  • Loading branch information...
commit 2d7da61bc51e7c31665344dc1d059bc8dc7e2159 1 parent 504c0d7
Ronni Rasmussen authored

Showing 2 changed files with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. +3 3 lib/measurement.rb
  2. +1 1  measurement.gemspec
6 lib/measurement.rb
@@ -6,8 +6,8 @@ def self.included(base)
6 6 def measurement_convert(name, from, to)
7 7 from = from.call if from.is_a?(Proc)
8 8 to = to.call if to.is_a?(Proc)
9   -
10   - self[name] = self[name].from(from).to(to).to_f.round(3) if !self[name].nil? && from != to
  9 +
  10 + self[name] = self[name].from(from).to(to).to_f.round(3) if from != to
11 11 end
12 12
13 13 module ClassMethods
@@ -24,7 +24,7 @@ def measurement(*args, &block)
24 24 measurement_convert(name, options[:database_unit], options[:model_unit])
25 25 end
26 26
27   - after_initialize do |record|
  27 + after_find do |record|
28 28 measurement_convert(name, options[:database_unit], options[:model_unit])
29 29 end
30 30 end
2  measurement.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6 6
7 7 s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8 8 s.authors = ["Ronni Steen Rasmussen"]
9   - s.date = "2012-03-13"
  9 + s.date = "2012-03-21"
10 10 s.description = "Automaticly convert measurements units."
11 11 s.email = "ronni.rasmussen@gmail.com"
12 12 s.extra_rdoc_files = ["README.md", "lib/measurement.rb"]

0 comments on commit 2d7da61

Please sign in to comment.
Something went wrong with that request. Please try again.