Skip to content

Commit

Permalink
Remove dependency on UUID in order to get key names that agree with A…
Browse files Browse the repository at this point in the history
…R object ID
  • Loading branch information
jsl committed May 13, 2009
1 parent 6192296 commit 0f69166
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.rdoc
Expand Up @@ -36,8 +36,6 @@ Getting started with HashPipe is easy.

config.gem "jsl-hashpipe", :lib => 'hashpipe', :source => 'http://gems.github.com'

* Add a column :uuid of type String, unique to the table where you want to use an hashpipe attribute (hattr)

* If you wanted to serialize an attribute 'elephant' in model Foo, you would call hattr :elephant in your model.
For example, class 'Foo' may look like:

Expand Down
9 changes: 1 addition & 8 deletions lib/hashpipe.rb
@@ -1,8 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), %w[hashpipe archived_attribute] ))
require File.expand_path(File.join(File.dirname(__FILE__), %w[hashpipe global_configuration] ))

require 'uuid'

module HashPipe

def self.included(base)
Expand All @@ -20,8 +18,7 @@ def hattr(*args)
if archived_attribute_definitions.nil?
write_inheritable_attribute(:archived_attribute_definitions, {})

before_save :generate_uuid
before_save :save_archived_attributes
after_save :save_archived_attributes
before_destroy :destroy_archived_attributes
end

Expand Down Expand Up @@ -72,10 +69,6 @@ def destroy_archived_attributes
end
end

def generate_uuid
self.uuid = UUID.new.generate if self.new_record?
end

end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hashpipe/moneta_backend.rb
Expand Up @@ -34,7 +34,7 @@ def require_moneta_library_for(cache_klass)
def key_name
[ table_name_from(@archived_attribute),
@archived_attribute.name,
@archived_attribute.instance.uuid ].join('/')
@archived_attribute.instance.id ].join('/')
end

def table_name_from(archived_attribute)
Expand Down
2 changes: 1 addition & 1 deletion spec/hashpipe_spec.rb
Expand Up @@ -47,7 +47,7 @@ class Story < ActiveRecord::Base
}.should_not change(@bear_story, :uuid)
end

[:generate_uuid, :save_archived_attributes, :destroy_archived_attributes].each do |sym|
[:save_archived_attributes, :destroy_archived_attributes].each do |sym|
it "should respond to attached storage method #{sym}" do
Story.new.should respond_to(sym)
end
Expand Down

0 comments on commit 0f69166

Please sign in to comment.