Sha256: 8cd199f6a01de7592847c073177946af70969e18a50a48dc429b4f978d6bcb99

Contents?: true

Size: 1.56 KB

Versions: 21

Compression:

Stored size: 1.56 KB

Contents

class ServiceInstanceHelper
  def self.new(instance)
    "#{instance.class.name.demodulize}Helper".constantize.new(instance)
  end
end

class UserProvidedServiceInstanceHelper
  def initialize(instance)
    @instance = instance
  end

  def service_label
    "user-provided"
  end

  def service_provider
    "n/a"
  end

  def version
    "n/a"
  end

  def plan_name
    "n/a"
  end

  def matches(opts = {})
    label = opts[:service]
    if label
      return label == service_label
    end

    true
  end

  def name
    @instance.name
  end

  def service_bindings
    @instance.service_bindings
  end
end

class ManagedServiceInstanceHelper
  def initialize(service_instance)
    @instance = service_instance
  end

  def service_label
    @instance.service_plan.service.label
  end

  def service_provider
    @instance.service_plan.service.provider
  end

  def version
    @instance.service_plan.service.version
  end

  def plan_name
    @instance.service_plan.name
  end

  def service_bindings
    @instance.service_bindings
  end

  def name
    @instance.name
  end

  def matches(opts = {})
    service = opts[:service]
    plan = opts[:plan]
    provider = opts[:provider]
    version = opts[:version]

    if service
      return false unless File.fnmatch(service, service_label)
    end

    if plan
      return false unless File.fnmatch(plan.upcase, plan_name.upcase)
    end

    if provider
      return false unless File.fnmatch(provider, service_provider)
    end

    if version
      return false unless File.fnmatch(version, self.version)
    end

    true
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
jdc-0.2.7 lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.5 lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.4 lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.3 lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.2 lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.3.pre lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.2.pre lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.1.pre lib/jdc/cli/service/service_instance_helper.rb
jdc-0.2.0 lib/jdc/cli/service/service_instance_helper.rb
cf-5.2.1.rc7 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.1.rc6 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.1.rc5 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.1.rc4 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.1.rc3 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.1.rc2 lib/cf/cli/service/service_instance_helper.rb
cf-5.2.0 lib/cf/cli/service/service_instance_helper.rb
cf-5.1.0.rc1 lib/cf/cli/service/service_instance_helper.rb
cf-5.0.0.rc4 lib/cf/cli/service/service_instance_helper.rb
cf-5.0.0.rc3 lib/cf/cli/service/service_instance_helper.rb
cf-4.2.9.rc5 lib/cf/cli/service/service_instance_helper.rb