Class: DBI::Type::Boolean

### Home Classes Methods

### In Files

- lib/dbi/types.rb

### Parent

DBI::Type::Null

### Methods

- ::parse

### Files

- ChangeLog
- LICENSE
- README

### Class/Module Index

Quicksearch

- DBI
- DBI::BaseDatabase
- DBI::BaseDriver
- DBI::BaseStatement
- DBI::Binary
- DBI::ColumnInfo
- DBI::DataError
- DBI::DatabaseError
- DBI::DatabaseHandle
- DBI::Date
- DBI::DriverHandle
- DBI::Error
- DBI::Handle
- DBI::HandleTracer
- DBI::IntegrityError
- DBI::InterfaceError
- DBI::InternalError
- DBI::NotImplementedError
- DBI::NotSupportedError
- DBI::OperationalError
- DBI::ProgrammingError
- DBI::Row
- DBI::SQL
- DBI::SQL::PreparedStatement
- DBI::StatementHandle
- DBI::Time
- DBI::Timestamp
- DBI::Type
- DBI::Type::Boolean
- DBI::Type::Decimal
- DBI::Type::Float
- DBI::Type::Integer
- DBI::Type::Null
- DBI::Type::Timestamp
- DBI::Type::Varchar
- DBI::TypeUtil
- DBI::Utils
- DBI::Utils::ConvParam
- DBI::Utils::TableFormatter
- DBI::Utils::XMLFormatter
- DBI::Warning
- Class

No matching classes.

# DBI::Type::Boolean

Represents a SQL BOOLEAN. Returns true/false. Falls back to Null.

### Public Class Methods

parse(obj) click to toggle source

    # File lib/dbi/types.rb, line 187
    def self.parse(obj)
        obj = super

        return nil if obj.nil?

        if obj == false or obj.kind_of? FalseClass
            return false
        elsif obj.kind_of? TrueClass
            return true
        else
            case obj
            when 't'
                return true
            when 'f'
                return false
            end

            if obj.respond_to? :to_i
                if obj.to_i == 0
                    return false
                else
                    return true
                end
            else
                # punt
                return nil
            end
        end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.