Module: ActiveModel::AttributeFilters::Common::Convert::ClassMethods
- Defined in:
- lib/attribute-filters/common_filters/convert.rb,
lib/attribute-filters/common_filters/convert.rb,
lib/attribute-filters/common_filters/convert.rb,
lib/attribute-filters/common_filters/convert.rb,
lib/attribute-filters/common_filters/convert.rb,
lib/attribute-filters/common_filters/convert.rb
Overview
This submodule contains class methods used to easily define filter.
Instance Method Summary collapse
-
#attributes_to_b(*args) ⇒ Object
(also: #convert_to_boolean, #convert_to_booleans, #converts_to_boolean, #converts_to_booleans)
Registers attributes that should be converted.
-
#attributes_to_f(*args) ⇒ Object
(also: #convert_to_float, #convert_to_floats, #converts_to_float, #converts_to_floats)
Registers attributes that should be converted.
-
#attributes_to_i(*args) ⇒ Object
(also: #convert_to_integer, #convert_to_integers, #converts_to_integer, #converts_to_integers)
Registers attributes that should be converted.
-
#attributes_to_numbers(*args) ⇒ Object
(also: #convert_to_number, #convert_to_numbers, #converts_to_number, #converts_to_numbers)
Registers attributes that should be converted.
-
#attributes_to_r(*args) ⇒ Object
(also: #convert_to_rational, #convert_to_rationals, #convert_to_fraction, #convert_to_fractions, #converts_to_rational, #converts_to_rationals, #converts_to_fraction, #converts_to_fractions)
Registers attributes that should be converted.
-
#attributes_to_s(*args) ⇒ Object
(also: #convert_to_string, #convert_to_strings, #converts_to_string, #converts_to_strings)
Registers attributes that should be converted.
Instance Method Details
#attributes_to_b(*args) ⇒ Object Also known as: convert_to_boolean, convert_to_booleans, converts_to_boolean, converts_to_booleans
Registers attributes that should be converted.
242 243 244 245 246 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 242 def attributes_to_b(*args) setup_attributes_that :should_be_boolean, args, { :to_b_default => [:default, :on_error, :to_b_default] }, :to_b_default end |
#attributes_to_f(*args) ⇒ Object Also known as: convert_to_float, convert_to_floats, converts_to_float, converts_to_floats
Registers attributes that should be converted.
146 147 148 149 150 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 146 def attributes_to_f(*args) setup_attributes_that :should_be_floats, args, { :to_f_default => [:default, :on_error, :to_f_default] }, :to_f_default end |
#attributes_to_i(*args) ⇒ Object Also known as: convert_to_integer, convert_to_integers, converts_to_integer, converts_to_integers
Registers attributes that should be converted.
114 115 116 117 118 119 120 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 114 def attributes_to_i(*args) setup_attributes_that :should_be_integers, args, { :to_i_default => [:default, :on_error, :to_i_default], :to_i_base => [:base, :with_base, :to_i_base] }, :to_i_base end |
#attributes_to_numbers(*args) ⇒ Object Also known as: convert_to_number, convert_to_numbers, converts_to_number, converts_to_numbers
Registers attributes that should be converted.
177 178 179 180 181 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 177 def attributes_to_numbers(*args) setup_attributes_that :should_be_numbers, args, { :to_num_default => [:default, :on_error, :to_number_default, :to_num_default] }, :to_num_default end |
#attributes_to_r(*args) ⇒ Object Also known as: convert_to_rational, convert_to_rationals, convert_to_fraction, convert_to_fractions, converts_to_rational, converts_to_rationals, converts_to_fraction, converts_to_fractions
Registers attributes that should be converted.
208 209 210 211 212 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 208 def attributes_to_r(*args) setup_attributes_that :should_be_rationals, args, { :to_r_default => [:default, :on_error, :to_r_default] }, :to_r_default end |
#attributes_to_s(*args) ⇒ Object Also known as: convert_to_string, convert_to_strings, converts_to_string, converts_to_strings
Registers attributes that should be converted.
70 71 72 73 74 75 76 |
# File 'lib/attribute-filters/common_filters/convert.rb', line 70 def attributes_to_s(*args) setup_attributes_that :should_be_strings, args, { :to_s_default => [:default, :on_error, :to_s_default], :to_s_base => [:base, :with_base, :to_s_base] }, :to_s_base end |