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.



1330
1331
1332
1333
1334
1335
1336
1337
# File 'lib/ruote/dashboard.rb', line 1330

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…



1365
1366
1367
1368
# File 'lib/ruote/dashboard.rb', line 1365

def method_missing(method_name, *args, &block)

  participant(method_name, *args, &block)
end

Instance Method Details

#_flushObject



1370
1371
1372
1373
# File 'lib/ruote/dashboard.rb', line 1370

def _flush

  @dashboard.participant_list = @list if @list
end

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



1353
1354
1355
1356
1357
1358
1359
# File 'lib/ruote/dashboard.rb', line 1353

def catchall(*args)

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

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

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



1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'lib/ruote/dashboard.rb', line 1339

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