Module: Metior::VCS::ClassMethods

Defined in:
lib/metior/vcs.rb

Overview

This module provided class methods for VCS implementation Modules that implement smart auto-loading of dependencies and classes.

Author:

  • Sebastian Staudt

Instance Method Summary collapse

Instance Method Details

#const_missing(const) ⇒ Object

Missing constants may indicate

Trying to access either the Actor, Commit or Repository class in a VCS Module will trigger auto-loading first.

Parameters:

  • const (Symbol)

    The symbolic name of the missing constant

See Also:



54
55
56
57
58
# File 'lib/metior/vcs.rb', line 54

def const_missing(const)
  init if [:Actor, :Commit, :Repository].include?(const)
  super unless const_defined? const
  const_get const
end

#initObject

This initializes the VCS's implementation Module

This requires the Actor, Commit and Repository classes for that VCS implementation.



64
65
66
67
68
69
70
71
# File 'lib/metior/vcs.rb', line 64

def init
  path = self::NAME.to_s
  require "metior/#{path}/actor"
  require "metior/#{path}/commit"
  require "metior/#{path}/repository"

  self
end

#not_supported(*features) ⇒ Object

Marks one or more features as not supported by the VCSs (or its implementation)

Parameters:

  • features (Array<Symbol>)

    The features that are not supported

See Also:



78
79
80
81
82
# File 'lib/metior/vcs.rb', line 78

def not_supported(*features)
  features.each do |feature|
    self.send(:class_variable_get, :@@features)[feature] = false
  end
end

#supports?(feature) ⇒ true, false

Checks if a specific feature is supported by the VCS (or its implementation)

Parameters:

  • feature (Symbol)

    The feature to check

Returns:

  • (true, false)

    true if the feature is supported

See Also:



91
92
93
# File 'lib/metior/vcs.rb', line 91

def supports?(feature)
  self.send(:class_variable_get, :@@features)[feature] == true
end