Class: EY::Collection::Abstract

Inherits:
Array
  • Object
show all
Defined in:
lib/engineyard/collection/abstract.rb

Direct Known Subclasses

Apps, Environments

Constant Summary collapse

COLLAB_MESSAGE =
<<-MSG
\nThis error is due to having access to another account's resources via the collaboration feature.
Specify --account ACCOUNT_NAME to resolve this ambiguity.
MSG

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.ambiguous_errorObject

Returns the value of attribute ambiguous_error.



44
45
46
# File 'lib/engineyard/collection/abstract.rb', line 44

def ambiguous_error
  @ambiguous_error
end

.invalid_errorObject

Returns the value of attribute invalid_error.



44
45
46
# File 'lib/engineyard/collection/abstract.rb', line 44

def invalid_error
  @invalid_error
end

Instance Method Details

#match_one(name_part) ⇒ Object



25
26
27
# File 'lib/engineyard/collection/abstract.rb', line 25

def match_one(name_part)
  named(name_part) || find_by_unambiguous_substring(name_part)
end

#match_one!(name_part) ⇒ Object



29
30
31
# File 'lib/engineyard/collection/abstract.rb', line 29

def match_one!(name_part)
  match_one(name_part) or raise invalid_error(name_part)
end

#named(name, account_name = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/engineyard/collection/abstract.rb', line 11

def named(name, =nil)
  candidates = find_all do |x|
    if 
      x.name == name && x..name == 
    else
      x.name == name
    end
  end
  if candidates.size > 1
    raise ambiguous_error(name, candidates.map {|e| e.name}, COLLAB_MESSAGE )
  end
  candidates.first
end