Class: Prick::Build::ModuleNode

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

Instance Attribute Summary collapse

Attributes inherited from Node

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

Instance Method Summary collapse

Methods inherited from Node

#dir, #dump, #lines, #name, #prefix_lines, #relpath, #schema, #schema=, #source, #source_lines, #to_s

Constructor Details

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

Returns a new instance of ModuleNode.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/prick/builder/node.rb', line 112

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.



109
110
111
# File 'lib/prick/builder/node.rb', line 109

def command
  @command
end

#klassObject (readonly)

Returns the value of attribute klass.



108
109
110
# File 'lib/prick/builder/node.rb', line 108

def klass
  @klass
end

Instance Method Details

#callObject



127
128
129
# File 'lib/prick/builder/node.rb', line 127

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

#inspectObject



131
# File 'lib/prick/builder/node.rb', line 131

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

#objectObject



110
# File 'lib/prick/builder/node.rb', line 110

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