Sha256: da3319c6acf4e77960414421fc8f2317175c3bb9b65a467dd47ef51a0461cbb2
Contents?: true
Size: 854 Bytes
Versions: 11
Compression:
Stored size: 854 Bytes
Contents
require 'engineyard/error' module EY module Collection class Environments < Array def named(name) find {|e| e.name == name} end def named!(name) named(name) or raise EnvironmentError, "Environment '#{name}' can't be found\nYou can create it at #{EY.config.endpoint}" end def match_one(name_part) named(name_part) || find_by_unambiguous_substring(name_part) end def match_one!(name_part) match_one(name_part) or raise NoEnvironmentError.new(name_part) end private def find_by_unambiguous_substring(name_part) candidates = find_all{|e| e.name[name_part] } if candidates.size > 1 raise AmbiguousEnvironmentName.new(name_part, candidates.map {|e| e.name}) end candidates.first end end end end
Version data entries
11 entries across 11 versions & 1 rubygems