Class: Terrazzo::Field::Money
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
associative?, default_options, eager_load?, #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
Class Method Details
.field_type ⇒ Object
27 28 29 |
# File 'lib/terrazzo/field/money.rb', line 27 def field_type "number" end |
Instance Method Details
#serializable_options(page = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/terrazzo/field/money.rb', line 14 def (page = nil) opts = {} opts[:prefix] = [:prefix] if .key?(:prefix) opts[:suffix] = [:suffix] if .key?(:suffix) opts[:decimals] = [:decimals] if .key?(:decimals) # Default to 2 decimal places for currency opts[:decimals] ||= 2 opts end |
#serialize_value(_mode) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/terrazzo/field/money.rb', line 4 def serialize_value(_mode) return nil if data.nil? if data.respond_to?(:to_f) data.to_f else data end end |