Class: Object
Overview
Basic, add an alias_method to the object class
Add returning to the object
Instance Method Summary
collapse
#load_pool, #reload!
#available_bases, #header, #pool_describe, #subheader
#define_resource, #virtual_resource
#cloud, #clouds, #with_cloud
#pool, #pools, #remove_pool, #reset!, #with_pool
Methods included from PoolParty
#available_custom_resources, #logger, #register_remote_base, #remote_bases
#clear_base_directory, #copy_file_to_storage_directory, #copy_template_to_storage_directory, #make_base_directory, #make_base_path, #make_template_directory, #write_to_file, #write_to_file_in_storage_directory, #write_to_temp_file
Instance Method Details
#alias_method(new_id, original_id) ⇒ Object
12
13
14
15
|
# File 'lib/poolparty/core/object.rb', line 12
def alias_method(new_id, original_id)
original = self.method(original_id).to_proc
define_method(new_id){|*args| original.call(*args)}
end
|
#block_instance_eval(*args, &block) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/poolparty/core/object.rb', line 39
def block_instance_eval(*args, &block)
return instance_eval(*args,&block) unless block_given? && !block.arity.zero?
old_method = (self.class.instance_method(:__) rescue nil)
self.class.send(:define_method, :__, &block)
block_method = self.class.instance_method(:__)
if old_method
self.class.send(:define_method, :__, old_method)
else
self.class.send(:remove_method, :__)
end
block_method.bind(self).call(*args)
end
|
#extended(&block) ⇒ Object
25
26
27
28
|
# File 'lib/poolparty/core/object.rb', line 25
def extended(&block)
block.in_context(self).call
self
end
|
51
52
53
|
# File 'lib/poolparty/core/object.rb', line 51
def meta_def name, &blk
(class << self; self; end).instance_eval { define_method name, &blk }
end
|
#my_methods ⇒ Object
6
7
8
|
# File 'lib/poolparty/core/object.rb', line 6
def my_methods
self.methods.sort - (self.class.methods + self.class.superclass.methods)
end
|
#returning(receiver) {|receiver| ... } ⇒ Object
21
22
23
24
|
# File 'lib/poolparty/core/object.rb', line 21
def returning(receiver)
yield receiver
receiver
end
|
#to_option_string ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/poolparty/core/object.rb', line 29
def to_option_string
case self.class
when String
self.to_option_string
when Array
self.each {|a| a.to_option_string }.join(" ")
else
"#{self}"
end
end
|
9
10
11
|
# File 'lib/poolparty/core/object.rb', line 9
def to_os
self
end
|
#with_options(opts = {}, parent = self, &block) ⇒ Object
16
17
18
19
20
|
# File 'lib/poolparty/core/object.rb', line 16
def with_options(opts={}, parent=self, &block)
@p = parent.clone
@p.options.merge!(opts)
@p.instance_eval &block if block
end
|