Class: Linen::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/linen/workspace.rb

Overview

The semi-specialized binding in which commands are executed.

Authors

Copyright © 2007 Laika, Inc.

This code released under the terms of the BSD license.

Version

$Id: workspace.rb 390 2007-11-19 22:21:12Z bbleything $

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



48
49
50
# File 'lib/linen/workspace.rb', line 48

def method_missing( *args )
	@@handler.send( *args )
end

Class Method Details

.handlerObject



52
53
54
# File 'lib/linen/workspace.rb', line 52

def self::handler
	return @@handler
end

.register_handler(handler_class) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/linen/workspace.rb', line 21

def self::register_handler( handler_class )
	raise Linen::WorkspaceError,
		"Can only register subclasses of Linen::Handler" unless
			handler_class < Linen::Handler

	@@handler = handler_class
end

Instance Method Details

#add_values(hash) ⇒ Object

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
# File 'lib/linen/workspace.rb', line 39

def add_values( hash )
	raise ArgumentError, "must send a hash" unless
		hash.is_a? Hash

	hash.each do |k,v|
		self.set_value k, v
	end
end

#set_value(name, value) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/linen/workspace.rb', line 29

def set_value( name, value )
	# add getter
	(class << self ; self ; end).instance_eval {
		attr_reader name.to_s.intern
	}

	# add ivar
	instance_variable_set "@#{name}", value
end