Class: Redmine::FieldFormat::FloatFormat

Inherits:
Numeric show all
Defined in:
lib/redmine/field_format.rb

Instance Method Summary collapse

Methods inherited from Numeric

#order_statement

Methods inherited from Base

#before_custom_field_save, #bulk_edit_tag, #cast_custom_value, #cast_value, #edit_tag, field_attributes, #formatted_custom_value, #formatted_value, #group_statement, #join_for_order_statement, #label, #name, #order_statement, #possible_custom_value_options, #possible_values_options, #target_class, #validate_custom_field, #validate_custom_value

Methods included from I18n

#current_language, #day_letter, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #languages_options, #ll, #month_name, #set_language_if_valid, #valid_languages

Instance Method Details

#cast_single_value(custom_field, value, customized = nil) ⇒ Object


387
388
389
# File 'lib/redmine/field_format.rb', line 387

def cast_single_value(custom_field, value, customized=nil)
  value.to_f
end

#query_filter_options(custom_field, query) ⇒ Object


397
398
399
# File 'lib/redmine/field_format.rb', line 397

def query_filter_options(custom_field, query)
  {:type => :float}
end

#validate_single_value(custom_field, value, customized = nil) ⇒ Object


391
392
393
394
395
# File 'lib/redmine/field_format.rb', line 391

def validate_single_value(custom_field, value, customized=nil)
  errs = super
  errs << ::I18n.t('activerecord.errors.messages.invalid') unless (Kernel.Float(value) rescue nil)
  errs
end