Sha256: 4a1c8da811130213362c4b1e68b0a7e43b1b46345958482757c755e7249b0e06

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 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 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
      self.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-2.8.1 lib/lazier/boolean.rb
lazier-2.8.0 lib/lazier/boolean.rb
lazier-2.7.0 lib/lazier/boolean.rb