class FactoryBot::UriManager
@api private
Attributes
Public Class Methods
Source
# 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
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"
Source
# 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
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
Public Instance Methods
Private Instance Methods
Source
# File lib/factory_bot/uri_manager.rb, line 53 def build_uri_list @endpoints.each do |endpoint| if @paths.any? @paths.each { |path| @uri_list << build_uri(path, endpoint) } else @uri_list << build_uri(endpoint) end end end