Sha256: b3119c978d8f3324d3bed8cbf94b950b5acc1cad301b5318c4d9b301453d4d4d

Contents?: true

Size: 491 Bytes

Versions: 11

Compression:

Stored size: 491 Bytes

Contents

# Extensions for ruby classes

class Array

  # Holds the total number of pagination results
  attr_accessor :total

end

class String

  # Adding a to_bool method
  def to_bool
    return true if self =~ (/^(true|yes|t|y|[1-9]+)$/i)
    return false if self.empty? || self =~ (/^(false|no|n|f|0)$/i)

    raise ArgumentError.new %{invalid value: #{self}}
  end

end

module BSON
  class ObjectId

    # Override the to_json method
    def as_json(o = {})
      self.to_s
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongocore-0.5.1 lib/mongocore/ext.rb
mongocore-0.5.0 lib/mongocore/ext.rb
mongocore-0.4.5 lib/mongocore/ext.rb
mongocore-0.4.4 lib/mongocore/ext.rb
mongocore-0.4.3 lib/mongocore/ext.rb
mongocore-0.4.2 lib/mongocore/ext.rb
mongocore-0.4.1 lib/mongocore/ext.rb
mongocore-0.4.0 lib/mongocore/ext.rb
mongocore-0.3.2 lib/mongocore/ext.rb
mongocore-0.3.1.1 lib/mongocore/ext.rb
mongocore-0.3.1 lib/mongocore/ext.rb