Class: WarehouseSupervisor::TemplateBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/warehouse_supervisor/template_binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program_name, hash) ⇒ TemplateBinding

Returns a new instance of TemplateBinding.



7
8
9
10
11
12
13
14
# File 'lib/warehouse_supervisor/template_binding.rb', line 7

def initialize(program_name, hash)
  @program_name = program_name
  @template = hash["template"]
  singleton = class << self; self end
  hash.each do |method_name, value|
    singleton.send(:define_method, method_name) {value} unless method_name == "template"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



24
25
26
# File 'lib/warehouse_supervisor/template_binding.rb', line 24

def method_missing(*args)
  nil
end

Instance Attribute Details

#_outputObject (readonly)

Returns the value of attribute _output.



5
6
7
# File 'lib/warehouse_supervisor/template_binding.rb', line 5

def _output
  @_output
end

Instance Method Details

#get_bindingObject



28
29
30
# File 'lib/warehouse_supervisor/template_binding.rb', line 28

def get_binding
  binding
end

#template(t) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/warehouse_supervisor/template_binding.rb', line 16

def template(t)
  if @template == t.to_s
    @output = "[program:#{@program_name}]"
    yield
    @_output = @output.dup
  end
end