class Vidalia::Interface

Attributes

init_block[RW]
interface[R]
name[R]

Public Class Methods

define(opts = {}, &block) click to toggle source

Define an Interface

This routine “stores” the defined Interface attributes in a Vidalia::InterfaceDefinition. Any subsequent call to instantiate an Interface object will copy that object from the InterfaceDefinition.

Options

Takes a hash as input where the current options are:

name

(required) specifies the name of the interface

block

(optional) specifies a block of code to be run when the interface object is initialized

Example

Vidalia::Interface.define(:name => "Blog API") {
  @db_password = ENV['BLOG_DB_PASSWORD']
  @db_userid = ENV['BLOG_DB_PASSWORD']
  @db_ip = ENV['BLOG_DB_IP']
  @db_port = ENV['BLOG_DB_PORT']
}
# File lib/vidalia/interface.rb, line 28
def self.define(opts = {}, &block)
  Vidalia::InterfaceDefinition.new(opts,&block)
end
get(name) click to toggle source

Get an Interface object by name

Options

This method takes one parameter:

name

(required) specifies the name of the Interface

Example

$$$ Example needed $$$
# File lib/vidalia/interface.rb, line 96
def self.get(name)
  return Vidalia::Interface.new(
    :name => name,
    :definition => Vidalia::InterfaceDefinition.find(name)
  )
end
new(opts = {}, &block) click to toggle source

Create an Interface (inherited from Vidalia::Artifact)

Initializes a Vidalia::Interface using the data set in Vidalia::Interface.define. If such data does not exist, this routine will error out. This ensures that all Interfaces have been predefined.

Options

Takes a hash as input where the current options are:

name

specifies the name of the Interface

Example

blog_api = Vidalia::Interface.new("Blog API")
Calls superclass method Vidalia::Artifact::new
# File lib/vidalia/interface.rb, line 48
def initialize(opts = {}, &block)
  o = {
    :name => nil,
    :definition => nil
  }.merge(opts)

  @type = Vidalia::Interface 
  super
end

Public Instance Methods

object(name) click to toggle source

Retrieve a child Object of this Interface by name

Options

This method takes one parameter:

name

specifies the name of the child Object

Example

$$$ Example needed $$$
# File lib/vidalia/interface.rb, line 70
def object(name)
  Vidalia::checkvar(name,String,self.class.ancestors,"name")
  child = get_child(name)
  unless child
    # Child does not yet exist.  Create it.
    child = Vidalia::Object.new(
      :name => name,
      :parent => self,
      :definition => @source_artifact.get_child(name)
    )
  end
  child
end