Sha256: 5eb22f4f47e845ec729c185b314483d5b53573cca4cc61a74f35b6fbb7b9ab98

Contents?: true

Size: 391 Bytes

Versions: 4

Compression:

Stored size: 391 Bytes

Contents

module ApiResource

  module Typecast

    TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set
    FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set

    module BooleanTypecaster

      def self.from_api(value)
        return nil if value.nil?
        TRUE_VALUES.include?(value)
      end

      def self.to_api(value)
        value
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_resource-0.6.25 lib/api_resource/typecasters/boolean_typecaster.rb
api_resource-0.6.24 lib/api_resource/typecasters/boolean_typecaster.rb
api_resource-0.6.23 lib/api_resource/typecasters/boolean_typecaster.rb
api_resource-0.6.22 lib/api_resource/typecasters/boolean_typecaster.rb