Class: Autoloaded::Specifications Private

Inherits:
Object
  • Object
show all
Defined in:
lib/autoloaded/specifications.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Holds regulations for autoloading.

Since:

  • 1.3

Instance Method Summary collapse

Instance Method Details

#exceptArray of Specification

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Specifications for excluding source files from being autoloaded.

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/autoloaded/specifications.rb', line 37

[:except, :only, :with].each do |attribute_name|
  define_method attribute_name do
    variable_name = "@#{attribute_name}"
    ((instance_variable_defined?(variable_name) &&
      instance_variable_get(variable_name)) ||
     []).tap do |value|
      instance_variable_set variable_name, value
    end
  end
end

#onlyArray of Specification

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Specifications for narrowing the set of source files being autoloaded as well as optionally renaming and/or reorganizing their corresponding constants.

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/autoloaded/specifications.rb', line 37

[:except, :only, :with].each do |attribute_name|
  define_method attribute_name do
    variable_name = "@#{attribute_name}"
    ((instance_variable_defined?(variable_name) &&
      instance_variable_get(variable_name)) ||
     []).tap do |value|
      instance_variable_set variable_name, value
    end
  end
end

#validate!(attribute) ⇒ Specifications

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluates the specifications for conflicts, in reference to the specified attribute.

Parameters:

  • attribute (Symbol)

    the attribute (:except, :only, or :with) being modified

Returns:

Raises:

  • (RuntimeError)

    attribute is :except and #only is not empty

  • (RuntimeError)

    attribute is :only and #except is not empty

See Also:

Since:

  • 1.3



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/autoloaded/specifications.rb', line 61

def validate!(attribute)
  other_attribute = {except: :only, only: :except}[attribute]
  if other_attribute
    unless send(attribute).empty? || send(other_attribute).empty?
      raise "can't specify `#{attribute}' when `#{other_attribute}' is " +
            'already specified'
    end
  end

  self
end

#withArray of Specification

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Specifications for renaming and/or reorganizing the constants corresponding to source files being autoloaded.

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/autoloaded/specifications.rb', line 37

[:except, :only, :with].each do |attribute_name|
  define_method attribute_name do
    variable_name = "@#{attribute_name}"
    ((instance_variable_defined?(variable_name) &&
      instance_variable_get(variable_name)) ||
     []).tap do |value|
      instance_variable_set variable_name, value
    end
  end
end