Class: Zemanta::Fetcher::Cache::Key
- Inherits:
-
Object
- Object
- Zemanta::Fetcher::Cache::Key
- Defined in:
- lib/zemanta/fetcher/cache/key.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ Key
constructor
A new instance of Key.
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Key
Returns a new instance of Key.
5 6 7 |
# File 'lib/zemanta/fetcher/cache/key.rb', line 5 def initialize(value) @value = value end |
Instance Method Details
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/zemanta/fetcher/cache/key.rb', line 9 def to_s if @value.is_a?(String) digest(@value) elsif @value.is_a?(Hash) digest(@value.sort.to_s) else raise "You are trying to use #{@value.class} as cache key. Only Strings and Hashes are supported." end end |