Module: Magellan::Cli::Resources

Defined in:
lib/magellan/cli/resources.rb,
lib/magellan/cli/resources/base.rb,
lib/magellan/cli/resources/team.rb,
lib/magellan/cli/resources/image.rb,
lib/magellan/cli/resources/stage.rb,
lib/magellan/cli/resources/worker.rb,
lib/magellan/cli/resources/project.rb,
lib/magellan/cli/resources/cloudsql.rb,
lib/magellan/cli/resources/authority.rb,
lib/magellan/cli/resources/container.rb,
lib/magellan/cli/resources/deletable.rb,
lib/magellan/cli/resources/organization.rb,
lib/magellan/cli/resources/client_version.rb,
lib/magellan/cli/resources/transaction_router.rb

Defined Under Namespace

Modules: Deletable Classes: Authority, Base, ClientVersion, Cloudsql, Container, Image, NotFound, Organization, Project, Stage, Team, TransactionRouter, Worker

Constant Summary collapse

MAPPING =
{
  "Organization"  => "organization",
  "Team"          => "team",
  "Project"       => "project",
  "Authority"     => "authority",
  "Stage"         => "stage",
  "ClientVersion" => "client_version",
  #"TransactionRouter" => "tr",
  "Worker"        => "worker",
  "Image"         => "image",
  "Container"     => "container",
  "Cloudsql"      => "cloudsql",
  # "CloudsqlInstance" => "cloudsql_instance", # This is not a resource
}

Class Method Summary collapse

Class Method Details

.concrete_classesObject



48
49
50
# File 'lib/magellan/cli/resources.rb', line 48

def concrete_classes
  @concrete_classes ||= MAPPING.keys.map{|c| self.const_get(c) }
end

.dependants_on(klass) ⇒ Object



52
53
54
55
56
# File 'lib/magellan/cli/resources.rb', line 52

def dependants_on(klass)
  name = klass.name.split(/::/).last
  res_name = MAPPING[name] or raise "unknown class named #{klass.name}"
  concrete_classes.select{|c| c.respond_to?(:resource_dependency) &&c.resource_dependency && !!c.resource_dependency[res_name] }
end