aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-07-11 11:02:23 -0400
committerGitHub <noreply@github.com>2016-07-11 11:02:23 -0400
commit968b59af872efe4fd562bea377765967dadea958 (patch)
treedecbefe27b29e9671322c728524e8b35d7ebf232
parenta45363a2fb53e0a016f33dd211c00b5d81764379 (diff)
parent3691c751e9cd0bd8dcbcbaf9824d64b740ade7ad (diff)
downloadrails-968b59af872efe4fd562bea377765967dadea958.tar.gz
rails-968b59af872efe4fd562bea377765967dadea958.tar.bz2
rails-968b59af872efe4fd562bea377765967dadea958.zip
Merge pull request #25575 from taboularasa/taboularasa/update-docs-ActiveModel__Type__Boolean
[ci skip] add class level documentation to ActiveModel::Type::Boolean
-rw-r--r--activemodel/lib/active_model/type/boolean.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/type/boolean.rb b/activemodel/lib/active_model/type/boolean.rb
index c1bce98c87..4e9d06a3ce 100644
--- a/activemodel/lib/active_model/type/boolean.rb
+++ b/activemodel/lib/active_model/type/boolean.rb
@@ -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