lib/administrate/field/number.rb in administrate-0.5.0 vs lib/administrate/field/number.rb in administrate-0.6.0

- old
+ new

@@ -2,15 +2,11 @@ module Administrate module Field class Number < Field::Base def to_s - if data.nil? - "-" - else - format_string % value - end + data.nil? ? "-" : format_string % value end private def format_string @@ -24,10 +20,12 @@ def suffix options[:suffix].to_s end def decimals - options.fetch(:decimals, 0) + _left, right = data.to_s.split(".") + default = right.nil? ? 0 : right.size + options.fetch(:decimals, default) end def value data * options.fetch(:multiplier, 1) end