Sha256: 9afb12619151d54dd0af279f4b59c2c7eee1ce6d5e06a372346f54a4968e7665

Contents?: true

Size: 639 Bytes

Versions: 6

Compression:

Stored size: 639 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2012 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

6 entries across 6 versions & 1 rubygems

Version Path
lazier-1.0.6 lib/lazier/boolean.rb
lazier-1.0.5 lib/lazier/boolean.rb
lazier-1.0.4 lib/lazier/boolean.rb
lazier-1.0.3 lib/lazier/boolean.rb
lazier-1.0.2 lib/lazier/boolean.rb
lazier-1.0.1 lib/lazier/boolean.rb