module Nova::Common::StarManagement::ClassMethods
Class methods.
Attributes
The name of the star.
@return [Symbol]
The type of the star.
@return [Symbol]
Public Instance Methods
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
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
Retrieves a star from a given target. The target should be in the format +[<type>.]<star
# File lib/nova/common/star_management.rb, line 118
def from_target(target)
type, star_name, action = target.scan(%r{\A(?:([\w]+)\.)?([\w]+)(?:\.([\w]+?))?\z}).first
type ||= :star
stars[type.intern][star_name.intern]
end
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
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
Retrieves the star with the given name.
@example
Nova::Star/Type.klass
@return [Class]
# 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
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
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
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
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