Sha256: d15d524cef474361dd337a3c94ef19f819446515b3a669d490d1b5d4964af2e5

Contents?: true

Size: 439 Bytes

Versions: 23

Compression:

Stored size: 439 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

TrueClass.class_eval do
  # :nodoc:
  def to_bool
    true
  end
end

FalseClass.class_eval do
  # :nodoc:
  def to_bool
    false
  end
end

NilClass.class_eval do
  # :nodoc:
  def to_bool
    false
  end
end

String.class_eval do
  # :nodoc:
  def to_bool
    match?(/^(true|1|t|y|yes)$/i)
  end
end

Numeric.class_eval do
  extend Forwardable

  def_delegators :to_s, :to_bool
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
ruby-rails-extensions-2.1.1 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.14 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.13 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.12 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.11 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.10 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.9 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.8 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.7 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.6 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.5 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.4 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.3 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.2 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.1.0.pre.rc.1 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.0.1 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.0.1.pre.rc.1 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.0.0 lib/ruby-rails-extensions/extensions/to_bool.rb
ruby-rails-extensions-2.0.0.pre.rc.1 lib/ruby-rails-extensions/extensions/to_bool.rb