Class: Lookbook::InputStore

Inherits:
Object
  • Object
show all
Defined in:
lib/lookbook/stores/input_store.rb

Constant Summary collapse

CONFIG_FILE =
"config/inputs.yml"
DEFAULTS =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ InputStore

Returns a new instance of InputStore.



10
11
12
13
14
15
16
17
# File 'lib/lookbook/stores/input_store.rb', line 10

def initialize(config = nil)
  @store = {}

  config.to_h.each do |name, opts|
    opts[:system] = true
    add_input(name, opts[:partial], opts.except(:partial))
  end
end

Instance Attribute Details

#storeObject (readonly)



7
8
9
# File 'lib/lookbook/stores/input_store.rb', line 7

def store
  @store
end

Class Method Details

.default_configObject



31
32
33
# File 'lib/lookbook/stores/input_store.rb', line 31

def self.default_config
  ConfigLoader.call(CONFIG_FILE)
end

.init_from_configObject



27
28
29
# File 'lib/lookbook/stores/input_store.rb', line 27

def self.init_from_config
  new(default_config)
end

Instance Method Details

#add_input(input, *args) ⇒ Object



19
20
21
# File 'lib/lookbook/stores/input_store.rb', line 19

def add_input(input, *args)
  store[normalize_name(input)] = build_config(input, *args)
end

#get_input(input) ⇒ Object



23
24
25
# File 'lib/lookbook/stores/input_store.rb', line 23

def get_input(input)
  store[normalize_name(input)]
end