Class: Prick::Build::ModuleNode

Inherits:
Node
  • Object
show all
Defined in:
lib/builder/node.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#args, #kind, #parent, #path, #phase, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#dump, #lines, #name, #prefix_lines, #schema, #schema=, #source_lines, #to_s

Constructor Details

#initialize(parent, phase, path, klass, command, args = nil) ⇒ ModuleNode

Returns a new instance of ModuleNode.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/builder/node.rb', line 97

def initialize(parent, phase, path, klass, command, args = nil)
  constrain klass, Symbol, String
  constrain command, Symbol, String

  super(parent, phase, :module, path, args)

  @klass = klass.to_sym
  @command = command.to_sym

  if !object
    Kernel.class_eval File.read(path)
    self.class.objects[@klass] = eval(klass.to_s).new(conn)
  end
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



94
95
96
# File 'lib/builder/node.rb', line 94

def command
  @command
end

#klassObject (readonly)

Returns the value of attribute klass.



93
94
95
# File 'lib/builder/node.rb', line 93

def klass
  @klass
end

Class Method Details

.objectsObject



121
# File 'lib/builder/node.rb', line 121

def self.objects() @@objects end

Instance Method Details

#callObject



112
113
114
# File 'lib/builder/node.rb', line 112

def call() 
  object.send(@command, *args)
end

#inspectObject



116
# File 'lib/builder/node.rb', line 116

def inspect() "#{path} #{klass}##{command}" end

#objectObject



95
# File 'lib/builder/node.rb', line 95

def object() self.class.objects[klass] end