class Fusuma::Config::Index

index for config.yml

Attributes

keys[R]

Public Class Methods

new(keys) click to toggle source
# File lib/fusuma/config/index.rb, line 8
def initialize(keys)
  @keys = case keys
          when Array
            keys.map do |key|
              if key.is_a? Key
                key
              else
                Key.new(key)
              end
            end
          else
            [Key.new(keys)]
          end
end

Public Instance Methods

cache_key() click to toggle source
# File lib/fusuma/config/index.rb, line 29
def cache_key
  case @keys
  when Array
    @keys.map(&:symbol).join(',')
  when Key
    @keys.symbol
  else
    raise 'invalid keys'
  end
end
inspect() click to toggle source
# File lib/fusuma/config/index.rb, line 23
def inspect
  @keys.map(&:inspect)
end
with_context() click to toggle source

@return [Index]

# File lib/fusuma/config/index.rb, line 41
def with_context
  keys = @keys.map do |key|
    next if Searcher.skip? && key.skippable

    if Searcher.fallback? && key.fallback
      key.fallback
    else
      key
    end
  end
  self.class.new(keys.compact)
end