Class: Terrazzo::Field::Number
- Defined in:
- lib/terrazzo/field/number.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Instance Method Summary collapse
Methods inherited from Base
associative?, default_options, eager_load?, #field_type, field_type, #form_input_attributes, #initialize, permitted_attribute, #required?, searchable?, sortable?, transform_param, with_options
Constructor Details
This class inherits a constructor from Terrazzo::Field::Base
Instance Method Details
#serializable_options(page = nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/terrazzo/field/number.rb', line 20 def (page = nil) opts = {} opts[:prefix] = [:prefix] if .key?(:prefix) opts[:suffix] = [:suffix] if .key?(:suffix) opts[:decimals] = [:decimals] if .key?(:decimals) opts end |
#serialize_value(mode) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/terrazzo/field/number.rb', line 6 def serialize_value(mode) return data if data.nil? || mode == :form value = .key?(:multiplier) ? data * [:multiplier] : data if [:format] formatter = [:format][:formatter] = [:format][:formatter_options].to_h ActiveSupport::NumberHelper.try(formatter, value, **) || value else value end end |