class Vidalia::InterfaceDefinition
Attributes
interface[R]
name[R]
parent[R]
Public Class Methods
find(name)
click to toggle source
Find an Interface
by name
Options
Takes one parameter:
name
-
(required) specifies the name of the
Interface
Example
$$$ Example needed $$$
# File lib/vidalia/interface_definition.rb, line 56 def self.find(name) Vidalia::checkvar(name,String,self.class.ancestors,"name") interface = nil @@interfaces.each do |i| if i.name == name interface = i end end interface end
new(opts = {}, &block)
click to toggle source
Create an Interface
Definition
Under the covers, the InterfaceDefinition
will create or find the associated Interface
definition. Any instantiated Interface
will be copied from this master copy.
Options
Takes two parameters: Takes a hash as input where the current options are:
name
-
(required) specifies the name of the
Interface
Takes a block to be executed at initialization time
Example
blog_api = Vidalia::InterfaceDefinition.new("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_definition.rb, line 30 def initialize(opts = {}, &block) o = { :name => nil }.merge(opts) Vidalia::checkvar(o[:name],String,self.class.ancestors,"name") # It's OK to "define" an Interface that has already been defined unless @interface = Vidalia::InterfaceDefinition.find(o[:name]) @interface = Vidalia::Interface.new(opts,&block) @@interfaces << @interface end end
Public Instance Methods
init(&block)
click to toggle source
Set's the interface's init block
# File lib/vidalia/dsl.rb, line 26 def init(&block) @interface.init_block = block end
object(name, &block)
click to toggle source
# File lib/vidalia/dsl.rb, line 30 def object(name, &block) obj_def = Vidalia::ObjectDefinition.new(name: name, parent: self) obj_def.instance_eval &block if block obj_def.object end