Skip to content

Commit

Permalink
Merge pull request #17 from durran/master
Browse files Browse the repository at this point in the history
Rename Generator#next to Generator#next_object_id.
  • Loading branch information
durran committed Apr 1, 2014
2 parents 44605b3 + b2881f3 commit 70cfc02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ext/bson/native.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,6 @@ void Init_native()
rb_define_private_method(string, "check_for_illegal_characters!", rb_string_check_for_illegal_characters, 0);

// Redefine the next method on the object id generator.
rb_undef_method(generator, "next");
rb_define_method(generator, "next", rb_object_id_generator_next, -1);
rb_undef_method(generator, "next_object_id");
rb_define_method(generator, "next_object_id", rb_object_id_generator_next, -1);
}
8 changes: 4 additions & 4 deletions lib/bson/object_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def marshal_load(data)
# @since 2.0.0
def to_bson(encoded = ''.force_encoding(BINARY))
repair if defined?(@data)
@raw_data ||= @@generator.next
@raw_data ||= @@generator.next_object_id
encoded << @raw_data
end

Expand Down Expand Up @@ -268,7 +268,7 @@ def from_string(string)
#
# @since 2.0.0
def from_time(time, options = {})
from_data(options[:unique] ? @@generator.next(time.to_i) : [ time.to_i ].pack("Nx8"))
from_data(options[:unique] ? @@generator.next_object_id(time.to_i) : [ time.to_i ].pack("Nx8"))
end

# Determine if the provided string is a legal object id.
Expand Down Expand Up @@ -337,14 +337,14 @@ def initialize
# object id counter. Will use the provided time if not nil.
#
# @example Get the next object id data.
# generator.next
# generator.next_object_id
#
# @param [ Time ] time The optional time to generate with.
#
# @return [ String ] The raw object id bytes.
#
# @since 2.0.0
def next(time = nil)
def next_object_id(time = nil)
@mutex.lock
begin
count = @counter = (@counter + 1) % 0xFFFFFF
Expand Down

0 comments on commit 70cfc02

Please sign in to comment.