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.



551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# File 'lib/flok/user_compiler.rb', line 551

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

  #Some macros expect controller instance
  @controller = self

  self.instance_eval(&block)

  #Ensure that choose_action exists
  actions = @ctx.actions_for_controller(@name)
  unless actions.detect{|e| e.name === :choose_action}
    @ctx.action self, :choose_action do
      on_entry %{
        Goto("#{actions[0].name}");
      }
    end
  end
end

Instance Attribute Details

#_on_entryObject

Returns the value of attribute _on_entry.



550
551
552
# File 'lib/flok/user_compiler.rb', line 550

def _on_entry
  @_on_entry
end

#_servicesObject

Returns the value of attribute _services.



550
551
552
# File 'lib/flok/user_compiler.rb', line 550

def _services
  @_services
end

#macrosObject

Returns the value of attribute macros.



550
551
552
# File 'lib/flok/user_compiler.rb', line 550

def macros
  @macros
end

#nameObject

Returns the value of attribute name.



550
551
552
# File 'lib/flok/user_compiler.rb', line 550

def name
  @name
end

#spots(*spots) ⇒ Object

Names of spots



588
589
590
# File 'lib/flok/user_compiler.rb', line 588

def spots
  @spots
end

Instance Method Details

#action(name, &block) ⇒ Object

Pass through action



597
598
599
# File 'lib/flok/user_compiler.rb', line 597

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

#choose_action(&block) ⇒ Object



583
584
585
# File 'lib/flok/user_compiler.rb', line 583

def choose_action &block
  @ctx.action self, :choose_action, &block
end

#macro(name, &block) ⇒ Object

Create an action macro



575
576
577
# File 'lib/flok/user_compiler.rb', line 575

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

#on_entry(str) ⇒ Object



579
580
581
# File 'lib/flok/user_compiler.rb', line 579

def on_entry str
  @_on_entry = _macro(str)
end

#services(*instance_names) ⇒ Object



592
593
594
# File 'lib/flok/user_compiler.rb', line 592

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