Class: Fusuma::Config::Index
- Inherits:
-
Object
- Object
- Fusuma::Config::Index
- Defined in:
- lib/fusuma/config/index.rb
Overview
index for config.yml
Defined Under Namespace
Classes: Key
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #cache_key ⇒ Object
-
#initialize(keys) ⇒ Index
constructor
A new instance of Index.
- #inspect ⇒ Object
- #with_context ⇒ Index
Constructor Details
#initialize(keys) ⇒ Index
Returns a new instance of Index.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
27 28 29 |
# File 'lib/fusuma/config/index.rb', line 27 def keys @keys end |
Instance Method Details
#cache_key ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/fusuma/config/index.rb', line 23 def inspect @keys.map(&:inspect) end |
#with_context ⇒ Index
41 42 43 44 45 46 47 48 49 50 51 52 |
# 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 |