Module: Charmkit::Plugins::Base::ClassMethods

Included in:
Charmkit
Defined in:
lib/charmkit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optsObject (readonly)

Generic options for this class, plugins store their options here.



27
28
29
# File 'lib/charmkit.rb', line 27

def opts
  @opts
end

Instance Method Details

#inherited(subclass) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/charmkit.rb', line 29

def inherited(subclass)
  subclass.instance_variable_set(:@opts, opts.dup)
  subclass.opts.each do |key, value|
    if value.is_a?(Enumerable) && !value.frozen?
      subclass.opts[key] = value.dup
    end
  end
end

#plugin(plugin, *args, &block) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/charmkit.rb', line 37

def plugin(plugin, *args, &block)
  plugin = Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
  plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
  self.include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
  self.extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
  plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
  nil
end