class FlightConfig::Globber::Matcher

Attributes

arity[R]
klass[R]
registry[R]

Public Class Methods

new(klass, arity, registry) click to toggle source
# File lib/flight_config/globber.rb, line 34
def initialize(klass, arity, registry)
  @klass = klass
  @arity = arity
  @registry = (registry || FlightConfig::Registry.new)
end

Public Instance Methods

keys() click to toggle source
# File lib/flight_config/globber.rb, line 40
def keys
  @keys ||= Array.new(arity) { |i| "arg#{i}" }
end
read(path) click to toggle source
# File lib/flight_config/globber.rb, line 51
def read(path)
  data = regex.match(path)
  init_args = keys.map { |key| data[key] }
  klass.read(*init_args, registry: registry)
end
regex() click to toggle source
# File lib/flight_config/globber.rb, line 44
def regex
  @regex ||= begin
    regex_inputs = keys.map { |k|  "(?<#{k}>.*)" }
    /#{klass.new(*regex_inputs).path}/
  end
end