Class: CapistranoNomadErbNamespace

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

Instance Method Summary collapse

Constructor Details

#initialize(context:, vars: {}) ⇒ CapistranoNomadErbNamespace

Returns a new instance of CapistranoNomadErbNamespace.



5
6
7
8
9
10
11
# File 'lib/capistrano/nomad/helpers/nomad.rb', line 5

def initialize(context:, vars: {})
  @context = context

  vars.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

rubocop:disable Style/MissingRespondToMissing



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/capistrano/nomad/helpers/nomad.rb', line 14

def method_missing(name, *args)
  instance_variable = "@#{name}"

  # First try to see if it's a variable we're trying to access which is stored in an instance variable otherwise try
  # to see if there's a local method defineds
  if instance_variable_defined?(instance_variable)
    instance_variable_get(instance_variable)
  elsif respond_to?(name)
    send(name, *args)
  end
end