Class: Capistrano::Command::Tree::ConditionBranch::Evaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, condition, server) ⇒ Evaluator

Returns a new instance of Evaluator.



58
59
60
61
62
# File 'lib/capistrano/command.rb', line 58

def initialize(config, condition, server)
  @configuration = config
  @condition = condition
  @server = server
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/capistrano/command.rb', line 72

def method_missing(sym, *args, &block)
  if server.respond_to?(sym)
    server.send(sym, *args, &block)
  elsif configuration.respond_to?(sym)
    configuration.send(sym, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



56
57
58
# File 'lib/capistrano/command.rb', line 56

def condition
  @condition
end

#configurationObject (readonly)

Returns the value of attribute configuration.



56
57
58
# File 'lib/capistrano/command.rb', line 56

def configuration
  @configuration
end

#serverObject (readonly)

Returns the value of attribute server.



56
57
58
# File 'lib/capistrano/command.rb', line 56

def server
  @server
end

Instance Method Details

#in?(role) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/capistrano/command.rb', line 64

def in?(role)
  configuration.roles[role].include?(server)
end

#resultObject



68
69
70
# File 'lib/capistrano/command.rb', line 68

def result
  eval(condition, binding)
end