Module: PulseMeter::Mixins::Dumper::ClassMethods
- Defined in:
- lib/pulse-meter/mixins/dumper.rb
Instance Method Summary collapse
-
#list_names ⇒ Array<String>
Lists all dumped objects’ names.
-
#list_objects ⇒ Array<Object>
Safely restores all dumped objects.
-
#restore(name) ⇒ Object
Restores object from Redis.
Instance Method Details
#list_names ⇒ Array<String>
Lists all dumped objects’ names
60 61 62 63 64 |
# File 'lib/pulse-meter/mixins/dumper.rb', line 60 def list_names PulseMeter.redis.hkeys(DUMP_REDIS_KEY) rescue raise RestoreError, "cannot get data from redis" end |
#list_objects ⇒ Array<Object>
Safely restores all dumped objects
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pulse-meter/mixins/dumper.rb', line 68 def list_objects objects = [] list_names.each do |name| begin objects << restore(name) rescue end end objects end |
#restore(name) ⇒ Object
Restores object from Redis
50 51 52 53 54 55 |
# File 'lib/pulse-meter/mixins/dumper.rb', line 50 def restore(name) serialized_obj = PulseMeter.redis.hget(DUMP_REDIS_KEY, name) YAML::load(serialized_obj) rescue raise RestoreError, "cannot restore #{name}" end |