Skip to content

Commit

Permalink
[ci skip] add class level documentation to ActiveModel::Type::Boolean
Browse files Browse the repository at this point in the history
add documentation of the behaviors of type coercion at the class level
  • Loading branch information
David Elliott committed Jul 11, 2016
1 parent 79bc066 commit 3691c75
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions activemodel/lib/active_model/type/boolean.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 3691c75

Please sign in to comment.