Skip to content

Commit

Permalink
uber hack to ignore disk_map
Browse files Browse the repository at this point in the history
  • Loading branch information
argvader committed May 20, 2015
1 parent 0605b7f commit 621a013
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion app/models/machine_info.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
require 'active_resource'

#########
## DiskMap only internally used to rewrite invalid key
## ie the 8:0 key in the example below
## 'disk_map' : {
# '8:0': {
# }
# }
#########
class DiskMap < BaseResource
include ActiveResource::Singleton

def find_or_create_resource_for(name)
name = name.to_s.gsub(':', '_').camelcase.to_sym
super("z_#{name}")
end
end

class MachineInfo < BaseResource
include ActiveResource::Singleton

self.site = "#{ENV['CADVISOR_PORT']}"

has_one :disk_map

def self.singleton_path(_prefix_options={}, _query_options=nil)
'/api/v1.0/machine'
'/api/v1.2/machine'
end
end
4 changes: 2 additions & 2 deletions spec/models/machine_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
it_behaves_like 'an active resource model'

describe '.singleton_path' do
it 'returns /api/v1.0/machine' do
expect(MachineInfo.singleton_path).to eq '/api/v1.0/machine'
it 'returns /api/v1.2/machine' do
expect(MachineInfo.singleton_path).to eq '/api/v1.2/machine'
end
end
end

0 comments on commit 621a013

Please sign in to comment.