Class: ActiveAdminAddons::NumberBuilder

Inherits:
CustomBuilder show all
Defined in:
lib/activeadmin_addons/addons/number_builder.rb

Constant Summary collapse

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
}

Instance Attribute Summary

Attributes inherited from CustomBuilder

#args, #block, #context, #model

Instance Method Summary collapse

Methods inherited from CustomBuilder

builder_method_name, create_view_methods, #initialize

Constructor Details

This class inherits a constructor from ActiveAdminAddons::CustomBuilder

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
# File 'lib/activeadmin_addons/addons/number_builder.rb', line 13

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