module Nova::Common::StarManagement::ClassMethods

Class methods.

Attributes

as[RW]

The name of the star.

@return [Symbol]

remote[W]
type[RW]

The type of the star.

@return [Symbol]

Public Instance Methods

/(other_class) click to toggle source

Just a way to write it; syntaxic sugar. It returns what was passed.

@example

Nova::Star/Type.something

@param other_class [Class] @return [Class] other_class.

# File lib/nova/common/star_management.rb, line 75
def /(other_class)
  other_class
end
[](star_name) click to toggle source

An accessor for {#stars}.

@param star_name [Symbol] @return [Hash, Class]

# File lib/nova/common/star_management.rb, line 56
def [](star_name)
  stars[star_name]
end
inherited(klass) click to toggle source

When the star is subclassed, add the subclass automatically to the star type list, unless it doesn’t have a proper name.

@api private

# File lib/nova/common/star_management.rb, line 24
def inherited(klass)
  return unless klass.name

  type = klass.name.gsub(/([A-Z])/) { |a| "_#{a.downcase}" }.gsub("::", "/")[1..-1].intern
  klass.star_type(type)
end
inspect() click to toggle source

Cleans up the inspect a little bit.

@return [String]

# File lib/nova/common/star_management.rb, line 63
def inspect
  @_inspect ||=
    ancestors.take_while { |x| x <= Star }.map(&:name).reverse.join("/").gsub(/\/\z/, "." + as.to_s)
end
method_missing(method, *args, &block) click to toggle source

Retrieves the star with the given name.

@example

Nova::Star/Type.klass

@return [Class]

Calls superclass method
# File lib/nova/common/star_management.rb, line 104
def method_missing(method, *args, &block)
  if (stars.key?(method) || stars[type].key?(method)) && args.length == 0
    stars[method] || stars[type][method]
  else
    super
  end
end
remote() click to toggle source

The remote to use, by default, for stars.

@!parse attr_reader :remote @return [Module]

# File lib/nova/common/star_management.rb, line 83
def remote
  @remote ||= Remote::Fake
end
star_type(name) click to toggle source

Adds the Star to the type list.

@param name [Symbol] the name of the star. @return [self]

# File lib/nova/common/star_management.rb, line 35
def star_type(name)
  types.delete_if { |_, v| v == self }
  types[name] = self
  self.type   = name
  stars[name] = {}
  self
end
stars() click to toggle source

All of the stars that have been defined. These are different from star types because they contain information such as events.

@return [Hash{Symbol => Class}]

# File lib/nova/common/star_management.rb, line 48
def stars
  @@stars ||= {}
end
types() click to toggle source

All of the types of stars. Should be a key-value pair, with the key being the name, and the value being the class.

@return [Hash{Symbol => Class}]

# File lib/nova/common/star_management.rb, line 15
def types
  @@types ||= {}
end