forked from zerohistory/toystore
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1474964
commit 22ec830
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'pp' | ||
require 'rubygems' | ||
require 'pathname' | ||
|
||
root_path = Pathname(__FILE__).dirname.join('..').expand_path | ||
lib_path = root_path.join('lib') | ||
$:.unshift(lib_path) | ||
|
||
require 'toystore' | ||
|
||
class Track | ||
include Toy::Store | ||
|
||
adapter :memory, {} | ||
|
||
key :hash, attributes: { | ||
bucket: String, | ||
track_id: SimpleUUID::UUID, | ||
} | ||
end | ||
|
||
track = Track.new(:bucket => '2012') | ||
|
||
pp track.id | ||
# => {:bucket=>"2012", :track_id=> <UUID#70194110090200 time: 2012-11-19 16:40:24 -0500, usecs: 149874 jitter: 11675517131681036675> | ||
|
||
pp track.bucket # => "2012" | ||
pp track.track_id # => <UUID#70194110090200 time: 2012-11-19 16:40:24 -0500, usecs: 149874 jitter: 11675517131681036675> | ||
|
||
track.bucket = '2011' | ||
|
||
pp track.id # => :bucket is now "2011" | ||
pp track.id_changed? # => true |