Class: MetaRequest::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_request/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Storage

Returns a new instance of Storage.



5
6
7
# File 'lib/meta_request/storage.rb', line 5

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/meta_request/storage.rb', line 3

def key
  @key
end

Instance Method Details

#readObject



15
16
17
# File 'lib/meta_request/storage.rb', line 15

def read
  File.read(json_file)
end

#write(value) ⇒ Object



9
10
11
12
13
# File 'lib/meta_request/storage.rb', line 9

def write(value)
  FileUtils.mkdir_p dir_path
  File.open(json_file, 'wb') { |file| file.write(value) }
  maintain_file_pool(MetaRequest.config.storage_pool_size)
end