Class: Rubble::Server
- Inherits:
-
Object
- Object
- Rubble::Server
- Defined in:
- lib/rubble/server.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#tool ⇒ Object
readonly
Returns the value of attribute tool.
Instance Method Summary collapse
- #configure_target(type, name, *params, &block) ⇒ Object
-
#initialize(tool, name) ⇒ Server
constructor
A new instance of Server.
- #method_missing(symbol, *arguments, &block) ⇒ Object
- #provide_target(type, name) ⇒ Object
- #respond_to?(symbol, include_private = false) ⇒ Boolean
Constructor Details
#initialize(tool, name) ⇒ Server
Returns a new instance of Server.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubble/server.rb', line 15 def initialize(tool, name) @tool = tool @name = name @log = Logging.logger[self] @targets = {} @rubble_dir = "/var/rubble" @user = 'root' @group = 'root' @deploy_dir = '#{env.name}/#{resource.type}/#{resource.name}' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *arguments, &block) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rubble/server.rb', line 45 def method_missing(symbol, *arguments, &block) if not @tool.nil? and @tool.is_target?(symbol) then configure_target(symbol, *arguments, &block) else super end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rubble/server.rb', line 8 def name @name end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
9 10 11 |
# File 'lib/rubble/server.rb', line 9 def targets @targets end |
#tool ⇒ Object (readonly)
Returns the value of attribute tool.
7 8 9 |
# File 'lib/rubble/server.rb', line 7 def tool @tool end |
Instance Method Details
#configure_target(type, name, *params, &block) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/rubble/server.rb', line 36 def configure_target(type, name, *params, &block) target = provide_target(type, name) do @tool.create_target(type, name, *params) end if not block.nil? then Docile.dsl_eval(target, &block) end end |
#provide_target(type, name) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/rubble/server.rb', line 27 def provide_target(type, name) group = @targets.fetch(type) do |k| @targets[type] = {} end group.fetch(name) do |k| group[name] = block_given? ? yield : @tool.create_target(type, name) end end |
#respond_to?(symbol, include_private = false) ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/rubble/server.rb', line 53 def respond_to?(symbol, include_private = false) if not @tool.nil? and @tool.is_target?(symbol) then true else super end end |