Sha256: bd2d3b9e3b5cafdeadf778570c42e2e4e3d9b396550982536884966b808806c7

Contents?: true

Size: 639 Bytes

Versions: 9

Compression:

Stored size: 639 Bytes

Contents

# encoding: utf-8
#
# 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

9 entries across 9 versions & 1 rubygems

Version Path
lazier-3.5.1 lib/lazier/boolean.rb
lazier-3.5.0 lib/lazier/boolean.rb
lazier-3.4.2 lib/lazier/boolean.rb
lazier-3.4.1 lib/lazier/boolean.rb
lazier-3.4.0 lib/lazier/boolean.rb
lazier-3.3.10 lib/lazier/boolean.rb
lazier-3.3.9 lib/lazier/boolean.rb
lazier-3.3.8 lib/lazier/boolean.rb
lazier-3.3.7 lib/lazier/boolean.rb