Class: EY::Collection::Abstract
- Defined in:
- lib/engineyard/collection/abstract.rb
Direct Known Subclasses
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
-
.ambiguous_error ⇒ Object
Returns the value of attribute ambiguous_error.
-
.invalid_error ⇒ Object
Returns the value of attribute invalid_error.
Instance Method Summary collapse
- #match_one(name_part) ⇒ Object
- #match_one!(name_part) ⇒ Object
- #named(name, account_name = nil) ⇒ Object
Class Attribute Details
.ambiguous_error ⇒ Object
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_error ⇒ Object
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, account_name=nil) candidates = find_all do |x| if account_name x.name == name && x.account.name == account_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 |