Sha256: 033c0ea5245e585d23f95893793ebc3354f0df4fe6c5793ae527374d06494dc0

Contents?: true

Size: 457 Bytes

Versions: 4

Compression:

Stored size: 457 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

    def as_json(o = {})
      self.to_s
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongocore-0.3.0 lib/mongocore/ext.rb
mongocore-0.2.5 lib/mongocore/ext.rb
mongocore-0.2.3 lib/mongocore/ext.rb
mongocore-0.2.2 lib/mongocore/ext.rb