Class: Wardrobe::PluginStore

Inherits:
Store
  • Object
show all
Defined in:
lib/wardrobe/plugin_store.rb

Instance Attribute Summary collapse

Attributes inherited from Store

#parent

Instance Method Summary collapse

Methods inherited from Store

#[], #del, #each, #freeze, #initialize, #merge, #method_missing, #values

Constructor Details

This class inherits a constructor from Wardrobe::Store

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wardrobe::Store

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



7
8
9
# File 'lib/wardrobe/plugin_store.rb', line 7

def store
  @store
end

Instance Method Details

#add(name, **args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wardrobe/plugin_store.rb', line 8

def add(name, **args)
  begin
    plugin = Wardrobe.plugins.fetch(name)
  rescue KeyError
    begin
      if require "wardrobe/plugins/#{name}"
        retry
      end
    rescue LoadError
      raise NoPluginRegisteredError, name
    end
  end
  mutate do
    store[name] = {
      klass: plugin,
      options: args
    }
  end
end