Sha256: a120c9e0af36955e8ebd47b1bc6ae8417a9840fcc75f803173f7c0f459be8dae

Contents?: true

Size: 622 Bytes

Versions: 8

Compression:

Stored size: 622 Bytes

Contents

#
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

module Lazier
  # 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
      is_a?(TrueClass) ? 1 : 0
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lazier-4.1.0 lib/lazier/boolean.rb
lazier-4.0.6 lib/lazier/boolean.rb
lazier-4.0.5 lib/lazier/boolean.rb
lazier-4.0.4 lib/lazier/boolean.rb
lazier-4.0.3 lib/lazier/boolean.rb
lazier-4.0.2 lib/lazier/boolean.rb
lazier-4.0.1 lib/lazier/boolean.rb
lazier-4.0.0 lib/lazier/boolean.rb