Method: Wakame::Service::Resource.id
- Defined in:
- lib/wakame/service.rb
.id(name = nil) ⇒ Object
Returns the hashed resource class name representation.
Resource.id() is as same as sha1.digest('Wakame::Service::Resource')
With an argument, tries to get the class name and take digest.
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
# File 'lib/wakame/service.rb', line 1077 def self.id(name=nil) res_class_name = case name when nil self.to_s when String raise "Invalid string as ruby constant: #{name}" unless name =~ /^(:-\:\:)?[A-Z]/ name.to_s when Class raise "Can't convert the argument: type of #{name.class}" unless name <= self name.to_s when Resource name.class.to_s else raise "Can't convert the argument: type of #{name.class}" end require 'digest/sha1' Digest::SHA1.hexdigest(res_class_name) end |