Class: CF::App::Service
- Inherits:
-
Object
- Object
- CF::App::Service
- Defined in:
- lib/cf-app-utils/cf/app/service.rb
Overview
:nodoc:
Instance Method Summary collapse
- #find_all_by_label(label) ⇒ Object
- #find_all_by_tag(tag) ⇒ Object
- #find_all_by_tags(tags) ⇒ Object
- #find_by_label(label) ⇒ Object
- #find_by_name(name) ⇒ Object
- #find_by_tag(tag) ⇒ Object
-
#initialize(env = ENV) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(env = ENV) ⇒ Service
Returns a new instance of Service.
5 6 7 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 5 def initialize(env = ENV) @env = env end |
Instance Method Details
#find_all_by_label(label) ⇒ Object
37 38 39 40 41 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 37 def find_all_by_label(label) all.select do |service| service['label'].match /^#{label}(-.*)?$/ end end |
#find_all_by_tag(tag) ⇒ Object
19 20 21 22 23 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 19 def find_all_by_tag(tag) all.select do |service| service['tags'].include?(tag) end end |
#find_all_by_tags(tags) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 25 def () all.select do |service| .inject(true) do |, tag| && service['tags'] && service['tags'].include?(tag) end end end |
#find_by_label(label) ⇒ Object
33 34 35 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 33 def find_by_label(label) find_all_by_label(label).first end |
#find_by_name(name) ⇒ Object
9 10 11 12 13 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 9 def find_by_name(name) all.detect do |service| service['name'] == name end end |
#find_by_tag(tag) ⇒ Object
15 16 17 |
# File 'lib/cf-app-utils/cf/app/service.rb', line 15 def find_by_tag(tag) find_all_by_tag(tag).first end |