Skip to content

Commit

Permalink
Change after_initialize to after_find.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronni Rasmussen authored and Ronni Rasmussen committed Mar 21, 2012
1 parent 504c0d7 commit 2d7da61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/measurement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion measurement.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 2d7da61

Please sign in to comment.