Class: Flok::UserCompilerController

Inherits:
Object
  • Object
show all
Includes:
UserCompilerMacro
Defined in:
lib/flok/user_compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UserCompilerMacro

#_macro

Constructor Details

#initialize(name, ctx, &block) ⇒ UserCompilerController

Returns a new instance of UserCompilerController.



471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/flok/user_compiler.rb', line 471

def initialize name, ctx, &block
  @name = name
  @ctx = ctx
  @spots = ['main']
  @macros = {}
  @_services = []

  #Some macros expect controller instance
  @controller = self

  self.instance_eval(&block)
end

Instance Attribute Details

#_on_entryObject

Returns the value of attribute _on_entry.



470
471
472
# File 'lib/flok/user_compiler.rb', line 470

def _on_entry
  @_on_entry
end

#_servicesObject

Returns the value of attribute _services.



470
471
472
# File 'lib/flok/user_compiler.rb', line 470

def _services
  @_services
end

#macrosObject

Returns the value of attribute macros.



470
471
472
# File 'lib/flok/user_compiler.rb', line 470

def macros
  @macros
end

#nameObject

Returns the value of attribute name.



470
471
472
# File 'lib/flok/user_compiler.rb', line 470

def name
  @name
end

#spots(*spots) ⇒ Object

Names of spots



494
495
496
# File 'lib/flok/user_compiler.rb', line 494

def spots
  @spots
end

Instance Method Details

#action(name, &block) ⇒ Object

Pass through action



503
504
505
# File 'lib/flok/user_compiler.rb', line 503

def action name, &block
  @ctx.action self, name, &block
end

#macro(name, &block) ⇒ Object

Create an action macro



485
486
487
# File 'lib/flok/user_compiler.rb', line 485

def macro name, &block
  @macros[name] = block
end

#on_entry(str) ⇒ Object



489
490
491
# File 'lib/flok/user_compiler.rb', line 489

def on_entry str
  @_on_entry = _macro(str)
end

#services(*instance_names) ⇒ Object



498
499
500
# File 'lib/flok/user_compiler.rb', line 498

def services *instance_names
  @_services = instance_names.map{|e| e.to_s}
end