Sha256: 2bd140b084df0125fb4f8bd046d31c5cc165833762305c60af3b4719fb91c20c

Contents?: true

Size: 681 Bytes

Versions: 8

Compression:

Stored size: 681 Bytes

Contents

# encoding: utf-8
#
# This file is part of the cowtech-extensions gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

module Cowtech
	module Extensions
    # Extension for the boolean values.
		module Boolean
			extend ::ActiveSupport::Concern

      # Converts the boolean to an integer.
      #
      # @return [Fixnum] `1` for `true`, `0` for `false`.
			def to_i
				(self == true) ? 1 : 0
			end

      # Returns the boolean itself for use in form helpers.
      #
      # @return [Boolean] The boolean value.
			def value
				self
			end
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cowtech-extensions-2.7.4 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.7.3 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.7.2 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.7.1 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.7.0 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.6.0 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.5.1 lib/cowtech-extensions/boolean.rb
cowtech-extensions-2.5.0 lib/cowtech-extensions/boolean.rb