Class: FactoryBot::UriManager Private
- Inherits:
-
Object
- Object
- FactoryBot::UriManager
- Defined in:
- lib/factory_bot/uri_manager.rb
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.
Instance Attribute Summary collapse
- #endpoints ⇒ Object readonly private
- #paths ⇒ Object readonly private
- #uri_list ⇒ Object readonly private
Class Method Summary collapse
-
.build_uri(*parts) ⇒ Object
private
Concatenate the parts, sripping leading/following slashes and returning a Symbolized String or nil.
Instance Method Summary collapse
-
#initialize(*endpoints, paths: []) ⇒ UriManager
constructor
private
Configures the new UriManager.
- #to_a ⇒ Object private
Constructor Details
#initialize(*endpoints, paths: []) ⇒ UriManager
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.
Configures the new UriManager
Arguments:
endpoints: (Array of Strings or Symbols)
the objects endpoints.
paths: (Array of Strings or Symbols)
the parent URIs to prepend to each endpoint
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/factory_bot/uri_manager.rb', line 35 def initialize(*endpoints, paths: []) if endpoints.empty? fail ArgumentError, "wrong number of arguments (given 0, expected 1+)" end @uri_list = [] @endpoints = endpoints.flatten @paths = Array(paths).flatten build_uri_list end |
Instance Attribute Details
#endpoints ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/uri_manager.rb', line 4 def endpoints @endpoints end |
#paths ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/uri_manager.rb', line 4 def paths @paths end |
#uri_list ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/uri_manager.rb', line 4 def uri_list @uri_list end |
Class Method Details
.build_uri(*parts) ⇒ Object
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.
Concatenate the parts, sripping leading/following slashes and returning a Symbolized String or nil.
Example:
build_uri(:my_factory, :my_trait, :my_sequence)
#=> :"myfactory/my_trait/my_sequence"
16 17 18 19 20 21 22 23 24 |
# File 'lib/factory_bot/uri_manager.rb', line 16 def self.build_uri(*parts) return nil if parts.empty? parts.join("/") .sub(/\A\/+/, "") .sub(/\/+\z/, "") .tr(" ", "_") .to_sym end |
Instance Method Details
#to_a ⇒ Object
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.
47 48 49 |
# File 'lib/factory_bot/uri_manager.rb', line 47 def to_a @uri_list.dup end |