Class: Ruote::ParticipantRegistrationProxy

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/ruote/dashboard.rb

Overview

Engine#register uses this proxy when it's passed a block.

Originally written by Torsten Schoenebaum for ruote-kit.

Instance Method Summary collapse

Constructor Details

#initialize(dashboard, clear) ⇒ ParticipantRegistrationProxy

Returns a new instance of ParticipantRegistrationProxy


1362
1363
1364
1365
1366
1367
1368
1369
# File 'lib/ruote/dashboard.rb', line 1362

def initialize(dashboard, clear)

  @dashboard = dashboard

  @dashboard.context.plist.clear if clear

  @list = clear ? [] : nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

Maybe a bit audacious…


1397
1398
1399
1400
# File 'lib/ruote/dashboard.rb', line 1397

def method_missing(method_name, *args, &block)

  participant(method_name, *args, &block)
end

Instance Method Details

#_flushObject


1402
1403
1404
1405
# File 'lib/ruote/dashboard.rb', line 1402

def _flush

  @dashboard.participant_list = @list if @list
end

#catchall(*args) ⇒ Object Also known as: catch_all


1385
1386
1387
1388
1389
1390
1391
# File 'lib/ruote/dashboard.rb', line 1385

def catchall(*args)

  klass = args.empty? ? Ruote::StorageParticipant : args.first
  options = args[1] || {}

  participant('.+', klass, options)
end

#participant(name, klass = nil, options = {}, &block) ⇒ Object


1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/ruote/dashboard.rb', line 1371

def participant(name, klass=nil, options={}, &block)

  if @list

    @list <<
      @dashboard.context.plist.to_entry(name, klass, options, block)

  else

    @dashboard.register_participant(
      name, klass, options.merge!(:override => false), &block)
  end
end