Class: Fusuma::Config::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/config/index.rb

Overview

index for config.yml

Defined Under Namespace

Classes: Key

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keysObject (readonly)

Returns the value of attribute keys.



22
23
24
# File 'lib/fusuma/config/index.rb', line 22

def keys
  @keys
end

Instance Method Details

#cache_keyObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/fusuma/config/index.rb', line 24

def cache_key
  case @keys
  when Array
    @keys.map(&:symbol).join(',')
  when Key
    @keys.symbol
  else
    raise 'invalid keys'
  end
end