Class: Fog::RiakCS::Usage::Mock

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/fog/riakcs/usage.rb,
lib/fog/riakcs/requests/usage/get_usage.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_FORMAT, Utils::DEFAULT_TYPES, Utils::TYPES_TO_STRING

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#format_and_types_to_path, #request_uri, #sanitize_and_convert_time

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



27
28
29
# File 'lib/fog/riakcs/usage.rb', line 27

def initialize(options = {})
  configure_uri_options(options)
end

Class Method Details

.dataObject



17
18
19
20
21
# File 'lib/fog/riakcs/usage.rb', line 17

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {}
  end
end

.resetObject



23
24
25
# File 'lib/fog/riakcs/usage.rb', line 23

def self.reset
  @data = nil
end

Instance Method Details

#dataObject



31
32
33
# File 'lib/fog/riakcs/usage.rb', line 31

def data
  self.class.data[riakcs_uri]
end

#get_usage(access_key, options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/riakcs/requests/usage/get_usage.rb', line 49

def get_usage(access_key, options = {})  
  Excon::Response.new.tap do |response|
    response.status = 200
    response.headers['Content-Type'] = 'application/json'
    response.body = {
      'Access' => { 
        'Nodes'   => [],
        'Errors'  => [] 
      },
      'Storage' => { 
        'Samples' => [],
        'Errors'  => [] 
      }
    }
  end
end

#reset_dataObject



35
36
37
# File 'lib/fog/riakcs/usage.rb', line 35

def reset_data
  self.class.data.delete(riakcs_uri)
end