mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
[ci skip] add class level documentation to ActiveModel::Type::Boolean
add documentation of the behaviors of type coercion at the class level
This commit is contained in:
parent
79bc06647c
commit
3691c751e9
1 changed files with 13 additions and 2 deletions
|
@ -1,9 +1,20 @@
|
|||
module ActiveModel
|
||||
module Type
|
||||
class Boolean < Value # :nodoc:
|
||||
# == Active \Model \Type \Boolean
|
||||
#
|
||||
# A class that behaves like a boolean type, including rules for coercion of user input.
|
||||
#
|
||||
# === Coercion
|
||||
# Values set from user input will first be coerced into the appropriate ruby type.
|
||||
# Coercion behavior is roughly mapped to Ruby's boolean semantics.
|
||||
#
|
||||
# - "false", "f" , "0", +0+ or any other value in +FALSE_VALUES+ will be coerced to +false+
|
||||
# - Empty strings are coerced to +nil+
|
||||
# - All other values will be coerced to +true+
|
||||
class Boolean < Value
|
||||
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].to_set
|
||||
|
||||
def type
|
||||
def type # :nodoc:
|
||||
:boolean
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue