Module: Vidalia

Defined in:
lib/vidalia.rb,
lib/vidalia/dsl.rb,
lib/vidalia/mysql.rb,
lib/vidalia/object.rb,
lib/vidalia/element.rb,
lib/vidalia/artifact.rb,
lib/vidalia/interface.rb,
lib/vidalia/object_definition.rb,
lib/vidalia/element_definition.rb,
lib/vidalia/interface_definition.rb

Overview

cat

something

something else

  • Top level comment about Vidalia

Defined Under Namespace

Classes: Artifact, Element, ElementDefinition, Interface, InterfaceDefinition, Mysql, Object, ObjectDefinition

Class Method Summary collapse

Class Method Details

.checkvar(thing, thingtype, procclass, thingname) ⇒ Object

Check the type and existence of a variable

Options

thing

specifies the veriable to check

thingtype

specifies the desired type of the variable data

procclass

specifies the class of the calling method

procname

specifies the name of the calling method

Example

Vidalia.log("Everything is fine - no bugs here.",:style => fatal_error)


66
67
68
69
70
71
72
73
74
# File 'lib/vidalia.rb', line 66

def Vidalia.checkvar(thing,thingtype,procclass,thingname)
  if thing
    unless thing.is_a?(thingtype)
      raise "#{procclass.first}: #{thingname} should be a #{thingtype}, but was a #{thing.class} instead"
    end
  else
    raise "#{procclass.first}: #{thingname} must be specified"
  end
end

.log(string, opts = {}) ⇒ Object

Write to the Vidalia log

The log can be predefined by Vidalia.set_logroutine

Options

string

specifies the string to write to the Vidalia log

opts

specifies a hash containing parameters to the Vidalia logging function

Example

Vidalia.log("Everything is fine - no bugs here.",:style => fatal_error)


49
50
51
# File 'lib/vidalia.rb', line 49

def Vidalia.log(string,opts = {})
  return Thread.current[:vidalia_logroutine].call(string,opts)
end

.set_logroutine(&block) ⇒ Object

Configure the logging routine to be used by Vidalia for this thread.

The routine you store here can be invoked by Vidalia.log

Options

&block

specifies the code block to be called whenever Vidalia needs to invoke a logger. This block should take a string followed by an optional hash as its parameters.

Example

Vidalia.set_logroutine { |string,opts|
  MyLogger::write(string,opts)
}


32
33
34
# File 'lib/vidalia.rb', line 32

def Vidalia.set_logroutine(&block)
  Thread.current[:vidalia_logroutine] = block
end