Class: RabbitMq::Plugin

Inherits:
Shared::Resource show all
Includes:
Shared::Deletable
Defined in:
lib/vas/rabbitmq/plugins.rb

Overview

A plugin in a RabbitMQ instance

Instance Attribute Summary collapse

Attributes included from Shared::Deletable

#collection

Attributes inherited from Shared::Resource

#location, #security

Instance Method Summary collapse

Methods included from Shared::Deletable

#delete

Constructor Details

#initialize(location, client) ⇒ Plugin

Returns a new instance of Plugin.



46
47
48
49
50
51
52
53
54
# File 'lib/vas/rabbitmq/plugins.rb', line 46

def initialize(location, client)
  super(location, client)

  @name = details['name']
  @version = details['version']

  @instance_location = Util::LinkUtils.get_link_href(details, 'group-instance')
  @state_location = Util::LinkUtils.get_link_href(details, 'state')
end

Instance Attribute Details

#nameString (readonly)

Returns the plugin’s name.

Returns:

  • (String)

    the plugin’s name



43
44
45
# File 'lib/vas/rabbitmq/plugins.rb', line 43

def name
  @name
end

#versionString (readonly)

Returns the plugin’s version.

Returns:

  • (String)

    the plugin’s version



40
41
42
# File 'lib/vas/rabbitmq/plugins.rb', line 40

def version
  @version
end

Instance Method Details

#disablevoid

This method returns an undefined value.

Disables the plugin



85
86
87
# File 'lib/vas/rabbitmq/plugins.rb', line 85

def disable
  client.post(@state_location, {:status => 'DISABLED'})
end

#enablevoid

This method returns an undefined value.

Enables the plugin



78
79
80
# File 'lib/vas/rabbitmq/plugins.rb', line 78

def enable
  client.post(@state_location, {:status => 'ENABLED'})
end

#instanceInstance

Returns the instance that contains the plugin.

Returns:

  • (Instance)

    the instance that contains the plugin



66
67
68
# File 'lib/vas/rabbitmq/plugins.rb', line 66

def instance
  @instance ||= Instance.new(@instance_location, client)
end

#plugin_imagePluginImage

Returns the plugin image, if any, that was used to create the plugin.

Returns:

  • (PluginImage)

    the plugin image, if any, that was used to create the plugin



57
58
59
60
61
62
63
# File 'lib/vas/rabbitmq/plugins.rb', line 57

def plugin_image
  if @plugin_image.nil?
    plugin_image_location = Util::LinkUtils.get_link_href(details, 'plugin-image')
    @plugin_image = PluginImage.new(plugin_image_location, client) unless plugin_image_location.nil?
  end
  @plugin_image
end

#stateString

Returns the state of the plugin.

Returns:

  • (String)

    the state of the plugin



71
72
73
# File 'lib/vas/rabbitmq/plugins.rb', line 71

def state
  client.get(@state_location)['status']
end

#to_sString

Returns a string representation of the plugin.

Returns:

  • (String)

    a string representation of the plugin



90
91
92
# File 'lib/vas/rabbitmq/plugins.rb', line 90

def to_s
  "#<#{self.class} name='#@name' version='#@version'>"
end