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.



617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/flok/user_compiler.rb', line 617

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.



616
617
618
# File 'lib/flok/user_compiler.rb', line 616

def _on_entry
  @_on_entry
end

#_servicesObject

Returns the value of attribute _services.



616
617
618
# File 'lib/flok/user_compiler.rb', line 616

def _services
  @_services
end

#macrosObject

Returns the value of attribute macros.



616
617
618
# File 'lib/flok/user_compiler.rb', line 616

def macros
  @macros
end

#nameObject

Returns the value of attribute name.



616
617
618
# File 'lib/flok/user_compiler.rb', line 616

def name
  @name
end

#spots(*spots) ⇒ Object

Names of spots



654
655
656
# File 'lib/flok/user_compiler.rb', line 654

def spots
  @spots
end

Instance Method Details

#action(name, &block) ⇒ Object

Pass through action



663
664
665
# File 'lib/flok/user_compiler.rb', line 663

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

#choose_action(&block) ⇒ Object



649
650
651
# File 'lib/flok/user_compiler.rb', line 649

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

#macro(name, &block) ⇒ Object

Create an action macro



641
642
643
# File 'lib/flok/user_compiler.rb', line 641

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

#on_entry(str) ⇒ Object



645
646
647
# File 'lib/flok/user_compiler.rb', line 645

def on_entry str
  @_on_entry = _macro(str)
end

#services(*instance_names) ⇒ Object



658
659
660
# File 'lib/flok/user_compiler.rb', line 658

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