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.



7
8
9
# File 'lib/meta_request/storage.rb', line 7

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

Instance Method Details

#readObject



17
18
19
# File 'lib/meta_request/storage.rb', line 17

def read
  File.read(json_file)
end

#write(value) ⇒ Object



11
12
13
14
15
# File 'lib/meta_request/storage.rb', line 11

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