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.



1174
1175
1176
1177
1178
1179
1180
1181
# File 'lib/ruote/dashboard.rb', line 1174

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…



1209
1210
1211
1212
# File 'lib/ruote/dashboard.rb', line 1209

def method_missing(method_name, *args, &block)

  participant(method_name, *args, &block)
end

Instance Method Details

#_flushObject



1214
1215
1216
1217
# File 'lib/ruote/dashboard.rb', line 1214

def _flush

  @dashboard.participant_list = @list if @list
end

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



1197
1198
1199
1200
1201
1202
1203
# File 'lib/ruote/dashboard.rb', line 1197

def catchall(*args)

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

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

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



1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/ruote/dashboard.rb', line 1183

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