Sha256: 096e53126aa2896c2e97e9adf8efa5b75b8cfbc980f79eb55792d6caf53baad0

Contents?: true

Size: 621 Bytes

Versions: 3

Compression:

Stored size: 621 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 a 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

3 entries across 3 versions & 1 rubygems

Version Path
lazier-4.2.2 lib/lazier/boolean.rb
lazier-4.2.1 lib/lazier/boolean.rb
lazier-4.2.0 lib/lazier/boolean.rb