Skip to content

Commit

Permalink
Minor code cleanup, adding license. Ready for release!
Browse files Browse the repository at this point in the history
  • Loading branch information
briandoll committed Aug 1, 2008
1 parent b63f5a1 commit 2ae4400
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2007 [name of plugin creator]

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Notes:
1) each property passed to the :from option must accept a to_s method call
2) I'm currently using crc32 hashing, since they make for nice tidy URL elements, which requires zlib

Copyright (c) 2008 BrianDoll, released under the MIT license
Copyright (c) 2008 Brian Doll, released under the MIT license

7 changes: 4 additions & 3 deletions lib/briandoll/acts_as_hashed.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module BrianDoll
module ActsAsHashed
module HashedMethods

def acts_as_hashed(options = {})
options[:from] ||= :name
class_inheritable_accessor :acts_as_hashed_options
Expand All @@ -15,18 +16,18 @@ def acts_as_hashed(options = {})

module InstanceMethods
private

def create_encryption_hash
properties_to_hash = acts_as_hashed_options[:from]
value_to_hash = ""
unless properties_to_hash.is_a? Array
value_to_hash = self.send(properties_to_hash).to_s
else
properties_to_hash.each do |prop|
value_to_hash += self.send(prop).to_s
end
value_to_hash = properties_to_hash.map { |prop| self.send(prop).to_s }.join
end
self.encryption_hash = Zlib.crc32(value_to_hash)
end

end
end
end
Expand Down

0 comments on commit 2ae4400

Please sign in to comment.