Sha256: 7d8a68862f964ac70b729fd39a798a1375b04abc8dffe80101852362089c3d27

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

module ActiveData
  module Model
    module Extensions
      module Boolean
        extend ActiveSupport::Concern

        MAPPING = {
          1 => true,
          0 => false,
          '1' => true,
          '0' => false,
          't' => true,
          'f' => false,
          'T' => true,
          'F' => false,
          true => true,
          false => false,
          'true' => true,
          'false' => false,
          'TRUE' => true,
          'FALSE' => false,
          'y' => true,
          'n' => false,
          'yes' => true,
          'no' => false,
        }

        module ClassMethods
          def active_data_type_cast value
            MAPPING[value]
          end
        end
      end
    end
  end
end

Boolean.send :include, ActiveData::Model::Extensions::Boolean

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_data-0.3.0 lib/active_data/model/extensions/boolean.rb
active_data-0.2.0 lib/active_data/model/extensions/boolean.rb
active_data-0.1.0 lib/active_data/model/extensions/boolean.rb