Sha256: fffeda2ebe316e6872e8e23a55a00a2e1d9b3fe367ba8ca290a72440b307ae1f
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
Contents
module ActiveAdminAddons class NumberBuilder < CustomBuilder NUMBER_TYPES = { currency: :number_to_currency, human: :number_to_human, human_size: :number_to_human_size, percentage: :number_to_percentage, phone: :number_to_phone, delimiter: :number_with_delimiter, precision: :number_with_precision } def render options[:as] = options.fetch(:as, :delimiter) if !NUMBER_TYPES.keys.include?(options[:as]) raise "Invalid number type. Options are: #{NUMBER_TYPES.keys.to_s}" end context.send(NUMBER_TYPES[options[:as]], data, options) end end module ::ActiveAdmin module Views class TableFor def number_column(*args, &block) column(*args) { |model| NumberBuilder.render(self, model, *args, &block) } end end class AttributesTable def number_row(*args, &block) row(*args) { |model| NumberBuilder.render(self, model, *args, &block) } end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems