Sha256: c65dcb9071fa8610141fd6fc5e1c0164632c7aed4e41049f6c20cacd1f09c7da

Contents?: true

Size: 639 Bytes

Versions: 20

Compression:

Stored size: 639 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 == true) ? 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

20 entries across 20 versions & 1 rubygems

Version Path
lazier-2.6.7 lib/lazier/boolean.rb
lazier-2.6.6 lib/lazier/boolean.rb
lazier-2.6.5 lib/lazier/boolean.rb
lazier-2.6.4 lib/lazier/boolean.rb
lazier-2.6.3 lib/lazier/boolean.rb
lazier-2.6.2 lib/lazier/boolean.rb
lazier-2.6.1 lib/lazier/boolean.rb
lazier-2.6.0 lib/lazier/boolean.rb
lazier-2.5.3 lib/lazier/boolean.rb
lazier-2.5.2 lib/lazier/boolean.rb
lazier-2.5.1 lib/lazier/boolean.rb
lazier-2.5.0 lib/lazier/boolean.rb
lazier-2.4.0 lib/lazier/boolean.rb
lazier-2.3.1 lib/lazier/boolean.rb
lazier-2.3.0 lib/lazier/boolean.rb
lazier-2.2.0 lib/lazier/boolean.rb
lazier-2.1.1 lib/lazier/boolean.rb
lazier-2.1.0 lib/lazier/boolean.rb
lazier-2.0.0 lib/lazier/boolean.rb
lazier-1.0.7 lib/lazier/boolean.rb