Class: Vedeu::Plugin Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/plugins/plugin.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A class responsible for plugin loading.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, gem) ⇒ Vedeu::Plugin

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Vedeu::Plugin.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

  • gem (Gem::Specification)

    The RubyGems gem.



33
34
35
36
37
38
# File 'lib/vedeu/plugins/plugin.rb', line 33

def initialize(name, gem)
  @name     = name
  @gem      = gem
  @gem_name = "vedeu_#{name}"
  @enabled  = false
end

Instance Attribute Details

#enabledBoolean Also known as: enabled?

Returns:



25
26
27
# File 'lib/vedeu/plugins/plugin.rb', line 25

def enabled
  @enabled
end

#gemString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


17
18
19
# File 'lib/vedeu/plugins/plugin.rb', line 17

def gem
  @gem
end

#gem_nameString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


21
22
23
# File 'lib/vedeu/plugins/plugin.rb', line 21

def gem_name
  @gem_name
end

#nameNilClass|Symbol|String (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The name of the model, the target model or the name of the associated model.

Returns:

  • (NilClass|Symbol|String)

    The name of the model, the target model or the name of the associated model.



13
14
15
# File 'lib/vedeu/plugins/plugin.rb', line 13

def name
  @name
end

Instance Method Details

#load!void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Load the plugin (require the gem).

Raises:

  • (Vedeu::Error::Fatal)

    When Vedeu does not understand that which the client application is attempting to achieve.



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vedeu/plugins/plugin.rb', line 44

def load!
  begin
    require gem_name unless enabled?
  rescue LoadError => error
    raise Vedeu::Error::Fatal,
          "Unable to load plugin #{gem_name} due to #{error}."
  rescue => error
    raise Vedeu::Error::Fatal,
          "require '#{gem_name}' failed with #{error}."
  end

  @enabled = true
end