Class: Autoloaded::Specification Private
- Inherits:
-
Object
- Object
- Autoloaded::Specification
- Defined in:
- lib/autoloaded/specification.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.
Describes regulations for autoloading.
Instance Attribute Summary collapse
-
#elements ⇒ Array
readonly
private
The elements of the specification.
Instance Method Summary collapse
-
#==(other_object) ⇒ true, false
private
Compares the Specification with the specified other_object.
-
#initialize(*elements) ⇒ Specification
constructor
private
Constructs a new Specification with the specified elements.
-
#match(source_filename) ⇒ Symbol, ...
private
Provides a matching constant from #elements for the specified source_filename.
Constructor Details
#initialize(*elements) ⇒ 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.
Constructs a new Specification with the specified elements.
Valid arguments include:
-
Symbol values
-
Array values comprising Symbol values
-
Hash values comprising Symbol, String, and/or Array values described above, which will autoload specified constants from their associated source files
-
Any combination of the options described above
31 32 33 |
# File 'lib/autoloaded/specification.rb', line 31 def initialize(*elements) @elements = elements end |
Instance Attribute Details
#elements ⇒ Array (readonly)
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.
The elements of the specification.
15 16 17 |
# File 'lib/autoloaded/specification.rb', line 15 def elements @elements end |
Instance Method Details
#==(other_object) ⇒ true, false
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.
Compares the Specification with the specified other_object.
41 42 43 44 45 |
# File 'lib/autoloaded/specification.rb', line 41 def ==(other_object) return false unless other_object.kind_of?(self.class) other_object.elements == elements end |
#match(source_filename) ⇒ Symbol, ...
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.
Provides a matching constant from #elements for the specified source_filename.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/autoloaded/specification.rb', line 57 def match(source_filename) matched = elements.detect do |element| if element.kind_of?(::Hash) element.each do |key, value| return value if source_filename_match?(source_filename, key) return key if source_filename_match?(source_filename, value) end false else source_filename_match? source_filename, element end end matched.kind_of?(::String) ? Inflection.to_constant_name(matched) : matched end |