Sha256: 53f640ad6b9469f8c4adb19f3e6961a86ada81927cef43d148c120a453c3cd1b

Contents?: true

Size: 688 Bytes

Versions: 23

Compression:

Stored size: 688 Bytes

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}"
      end

      context.send(NUMBER_TYPES[options[:as]], data, options)
    end
  end
end

ActiveAdminAddons::NumberBuilder.create_view_methods

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
activeadmin_addons-2.0.0.beta.4 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.10.2 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-2.0.0.beta.3 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.10.1 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-2.0.0.beta.2 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-2.0.0.beta.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.10.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.9.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.8.3 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.8.2 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons_rails6-1.7.2 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.7.1 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.7.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.6.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.5.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.4.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.3.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.2.0 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.1.2 lib/activeadmin_addons/addons/number_builder.rb
activeadmin_addons-1.1.1 lib/activeadmin_addons/addons/number_builder.rb