Class: AppEngine::Memcache::KeyMap
- Inherits:
-
Object
- Object
- AppEngine::Memcache::KeyMap
- Defined in:
- lib/appengine-apis/memcache.rb
Overview
:nodoc:
Instance Method Summary collapse
- #<<(key) ⇒ Object
-
#initialize(keys = []) ⇒ KeyMap
constructor
A new instance of KeyMap.
- #java_keys ⇒ Object
- #map_to_hash(java_map) ⇒ Object
- #missing_keys(keys) ⇒ Object
- #ruby_keys(keys) ⇒ Object
Constructor Details
#initialize(keys = []) ⇒ KeyMap
Returns a new instance of KeyMap.
527 528 529 530 531 532 533 |
# File 'lib/appengine-apis/memcache.rb', line 527 def initialize(keys=[]) @orig_keys = [] @map = {} keys.each do |key| self << key end end |
Instance Method Details
#<<(key) ⇒ Object
535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/appengine-apis/memcache.rb', line 535 def <<(key) @orig_keys << key string_key = if key key.to_s else key end @map[string_key] = key if string_key java.lang.String.new(string_key) else string_key end end |
#java_keys ⇒ Object
550 551 552 553 554 555 556 557 558 |
# File 'lib/appengine-apis/memcache.rb', line 550 def java_keys @map.keys.collect do |key| if key java.lang.String.new(key) else key end end end |
#map_to_hash(java_map) ⇒ Object
568 569 570 571 572 573 574 575 576 577 |
# File 'lib/appengine-apis/memcache.rb', line 568 def map_to_hash(java_map) hash = {} if java_map java_map.each do |key, value| value = yield(value) hash[@map[key]] = value end end hash end |
#missing_keys(keys) ⇒ Object
564 565 566 |
# File 'lib/appengine-apis/memcache.rb', line 564 def missing_keys(keys) @orig_keys - ruby_keys(keys) end |
#ruby_keys(keys) ⇒ Object
560 561 562 |
# File 'lib/appengine-apis/memcache.rb', line 560 def ruby_keys(keys) keys.collect {|key| @map[key]} end |