class Librato::Spaces
Public Instance Methods
find_all(config)
click to toggle source
# File lib/librato/spaces.rb, line 6 def find_all(config) config.map do |config| find(config['name']).tap { |space| space.config = config } end end
Private Instance Methods
all()
click to toggle source
# File lib/librato/spaces.rb, line 14 def all @all ||= fetch['spaces'].map do |data| Space.new(client, normalize(data)) end end
fetch()
click to toggle source
# File lib/librato/spaces.rb, line 25 def fetch JSON.parse(client.get(path).body) end
find(name)
click to toggle source
# File lib/librato/spaces.rb, line 20 def find(name) space = all.detect { |space| space.name == name } space || fail("Could not find space #{name}") end
normalize(data)
click to toggle source
# File lib/librato/spaces.rb, line 33 def normalize(data) data.merge('name' => data['name'].to_s.sub(/\s*\(#{account}\)\s*/, '')) end
path()
click to toggle source
# File lib/librato/spaces.rb, line 29 def path '/v1/spaces' end