Top Level Namespace

Defined Under Namespace

Modules: Cosmos, Manufactured, Missions, Motel, Omega, PasswordHelper, Stats, Users Classes: Array, Class, Fixnum, Float, Module, Object, String

Constant Summary collapse

ADMIN_METHODS =
{ :set   => admin_set, :run_callbacks => admin_run_callbacks }

Constants included from Motel

Motel::CARTESIAN_NORMAL_VECTOR, Motel::CLOSE_ENOUGH, Motel::LOCATION_EVENTS, Motel::MAJOR_CARTESIAN_AXIS, Motel::MINOR_CARTESIAN_AXIS

Instance Method Summary collapse

Methods included from Motel

angle_between, axis_angle, cross_product, dot_product, elliptical_path, gen_uuid, normalize, normalized?, orthogonal?, rand_vector, random_axis, rotate, rotated_angle

Methods included from Omega::Client::DSL

#asteroid, #asteroid_belt, #asteroid_field, #dock, #dsl, #galaxy, #gen_uuid, #interconnect, #invoke, #jump_gate, #loc, #login, #logout, #mission, #missions_event_handler, #moon, #moons, #notify, #orbit, #planet, #proxied_system, #rand_location, #rand_resource, #random_axis, #random_orbit, #resource, #role, #schedule_event, #ship, #station, #station_orbit, #system, #user

Instance Method Details

#dispatch_cosmos_rjr_create(dispatcher) ⇒ Object


59
60
61
62
# File 'lib/cosmos/rjr/create.rb', line 59

def dispatch_cosmos_rjr_create(dispatcher)
  m = Cosmos::RJR::CREATE_METHODS
  dispatcher.handle 'cosmos::create_entity', &m[:create_entity]
end

#dispatch_cosmos_rjr_get(dispatcher) ⇒ Object

module Cosmos::RJR


99
100
101
102
103
# File 'lib/cosmos/rjr/get.rb', line 99

def dispatch_cosmos_rjr_get(dispatcher)
  m = Cosmos::RJR::GET_METHODS
  dispatcher.handle ['cosmos::get_entities', 'cosmos::get_entity'],
                                                 &m[:get_entities]
end

#dispatch_cosmos_rjr_init(dispatcher) ⇒ Object

Dispatch init


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cosmos/rjr/init.rb', line 86

def dispatch_cosmos_rjr_init(dispatcher)
  # setup Cosmos::RJR module
  rjr = Object.new.extend(Cosmos::RJR)
  rjr.node.dispatcher = dispatcher
  rjr.node.dispatcher.env /cosmos::.*/, Cosmos::RJR
  rjr.node.dispatcher.add_module('cosmos/rjr/create')
  rjr.node.dispatcher.add_module('cosmos/rjr/get')
  rjr.node.dispatcher.add_module('cosmos/rjr/resources')
  rjr.node.dispatcher.add_module('cosmos/rjr/state')
  rjr.node.dispatcher.add_module('cosmos/rjr/interconnects')
  rjr.node.message_headers['source_node'] = 'cosmos'

  # create cosmos user
  begin rjr.node.invoke('users::create_user', rjr.user)
  rescue Exception => e ; end

  # grant cosmos user extra permissions
  role_id = "user_role_#{rjr.user.id}"
  Cosmos::RJR::PRIVILEGES.each { |p,e|
     rjr.node.invoke('users::add_privilege', role_id, p, e)
   }

  # log the cosmos user in
  session = rjr.node.invoke('users::login', rjr.user)
  rjr.node.message_headers['session_id'] = session.id
end

#dispatch_cosmos_rjr_inspect(dispatcher) ⇒ Object

TODO

  • total # of entities and # of entities of each type

  • total # of resources


12
13
14
15
16
17
# File 'lib/cosmos/rjr/inspect.rb', line 12

def dispatch_cosmos_rjr_inspect(dispatcher)
  #dispatcher.handle "cosmos::status" do
  #  {
  #  }
  #end
end

#dispatch_cosmos_rjr_interconnects(dispatcher) ⇒ Object

module Cosmos::RJR


38
39
40
41
# File 'lib/cosmos/rjr/interconnects.rb', line 38

def dispatch_cosmos_rjr_interconnects(dispatcher)
  m = Cosmos::RJR::INTERCONNECTS_METHODS
  dispatcher.handle 'cosmos::interconnects', &m[:interconnects]
end

#dispatch_cosmos_rjr_resources(dispatcher) ⇒ Object

module Cosmos::RJR


79
80
81
82
83
84
# File 'lib/cosmos/rjr/resources.rb', line 79

def dispatch_cosmos_rjr_resources(dispatcher)
  m = Cosmos::RJR::RESOURCES_METHODS
  dispatcher.handle 'cosmos::set_resource',  &m[:set_resource]
  dispatcher.handle 'cosmos::get_resource',  &m[:get_resource]
  dispatcher.handle 'cosmos::get_resources', &m[:get_resources]
end

#dispatch_cosmos_rjr_state(dispatcher) ⇒ Object


26
27
28
29
30
# File 'lib/cosmos/rjr/state.rb', line 26

def dispatch_cosmos_rjr_state(dispatcher)
  m = Cosmos::RJR::STATE_METHODS
  dispatcher.handle "cosmos::save_state",    &m[:save_state]
  dispatcher.handle "cosmos::restore_state", &m[:restore_state]
end

#dispatch_manufactured_rjr_admin(dispatcher) ⇒ Object


34
35
36
37
38
39
40
# File 'lib/manufactured/rjr/admin.rb', line 34

def dispatch_manufactured_rjr_admin(dispatcher)
  dispatcher.handle "manufactured::admin::set",
                     &ADMIN_METHODS[:set]

  dispatcher.handle "manufactured::admin::run_callbacks",
                     &ADMIN_METHODS[:run_callbacks]
end

#dispatch_manufactured_rjr_attack(dispatcher) ⇒ Object

module Manufactured::RJR


49
50
51
52
53
# File 'lib/manufactured/rjr/attack.rb', line 49

def dispatch_manufactured_rjr_attack(dispatcher)
  m = Manufactured::RJR::ATTACK_METHODS
  dispatcher.handle 'manufactured::attack_entity', &m[:attack_entity]
  # dispatcher.handle('manufactured::stop_attack', 'TODO')
end

#dispatch_manufactured_rjr_create(dispatcher) ⇒ Object


188
189
190
191
192
193
194
195
196
197
198
# File 'lib/manufactured/rjr/create.rb', line 188

def dispatch_manufactured_rjr_create(dispatcher)
  m = Manufactured::RJR::CREATE_METHODS
  dispatcher.handle 'manufactured::create_entity',    &m[:create_entity]
  dispatcher.handle 'manufactured::construct_entity', &m[:construct_entity]

  # register entity validation method w/ registry
  unless Manufactured::RJR.registry.validation_methods.
                           include?(m[:validate_user_attributes])
    Manufactured::RJR.registry.validation_callback &m[:validate_user_attributes]
  end
end

#dispatch_manufactured_rjr_dock(dispatcher) ⇒ Object

module Manufactured::RJR


97
98
99
100
101
# File 'lib/manufactured/rjr/dock.rb', line 97

def dispatch_manufactured_rjr_dock(dispatcher)
  m = Manufactured::RJR::DOCK_METHODS
  dispatcher.handle 'manufactured::dock',   &m[:dock]
  dispatcher.handle 'manufactured::undock', &m[:undock]
end

#dispatch_manufactured_rjr_follow(dispatcher) ⇒ Object


66
67
68
69
# File 'lib/manufactured/rjr/follow.rb', line 66

def dispatch_manufactured_rjr_follow(dispatcher)
  m = Manufactured::RJR::FOLLOW_METHODS
  dispatcher.handle 'manufactured::follow_entity', &m[:follow_entity]
end

#dispatch_manufactured_rjr_get(dispatcher) ⇒ Object


67
68
69
70
71
72
73
# File 'lib/manufactured/rjr/get.rb', line 67

def dispatch_manufactured_rjr_get(dispatcher)
  m = Manufactured::RJR::GET_METHODS
  dispatcher.handle ['manufactured::get',
                     'manufactured::get_entity',
                     'manufactured::get_entities'],
                      &m[:get_entities]
end

#dispatch_manufactured_rjr_init(dispatcher) ⇒ Object

Dispatch init


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/manufactured/rjr/init.rb', line 162

def dispatch_manufactured_rjr_init(dispatcher)
  Manufactured::RJR.registry.start
  Manufactured::RJR.registry.node = Manufactured::RJR.node

  # setup Manufactured::RJR module
  rjr = Object.new.extend(Manufactured::RJR)
  rjr.node.dispatcher = dispatcher
  rjr.node.dispatcher.env /manufactured::.*/, Manufactured::RJR
  rjr.node.dispatcher.add_module('manufactured/rjr/create')
  rjr.node.dispatcher.add_module('manufactured/rjr/get')
  rjr.node.dispatcher.add_module('manufactured/rjr/state')
  rjr.node.dispatcher.add_module('manufactured/rjr/subscribe_to')
  rjr.node.dispatcher.add_module('manufactured/rjr/remove_callbacks')
  rjr.node.dispatcher.add_module('manufactured/rjr/resources')
  rjr.node.dispatcher.add_module('manufactured/rjr/move')
  rjr.node.dispatcher.add_module('manufactured/rjr/follow')
  rjr.node.dispatcher.add_module('manufactured/rjr/stop')
  rjr.node.dispatcher.add_module('manufactured/rjr/dock')
  rjr.node.dispatcher.add_module('manufactured/rjr/mining')
  rjr.node.dispatcher.add_module('manufactured/rjr/attack')
  rjr.node.dispatcher.add_module('manufactured/rjr/loot')
  rjr.node.message_headers['source_node'] = 'manufactured'

  # create manufactured user
  begin rjr.node.invoke('users::create_user', rjr.user)
  rescue Exception => e ; end

  # grant manufactured user extra permanufactured
  role_id = "user_role_#{rjr.user.id}"
  Manufactured::RJR::PRIVILEGES.each { |p,e|
     rjr.node.invoke('users::add_privilege', role_id, p, e)
   }

  # log the manufactured user in
  session = rjr.node.invoke('users::login', rjr.user)
  rjr.node.message_headers['session_id'] = session.id

  # add callback for motel events, override environment it runs in
  m = Manufactured::RJR::CALLBACK_METHODS
  rjr.node.dispatcher.handle(['motel::on_movement', 'motel::on_rotation'],
                             &m[:motel_event])
  rjr.node.dispatcher.env ['motel::on_movement', 'motel::on_rotation'],
                          Manufactured::RJR
end

#dispatch_manufactured_rjr_inspect(dispatcher) ⇒ Object


40
41
42
43
44
45
# File 'lib/manufactured/rjr/inspect.rb', line 40

def dispatch_manufactured_rjr_inspect(dispatcher)
  m = Manufactured::RJR::INSPECT_METHODS

  dispatcher.handle "manufactured::command", &m[:get_cmd]
  dispatcher.handle "manufactured::status", &m[:get_status]
end

#dispatch_manufactured_rjr_loot(dispatcher) ⇒ Object

module Manufactured::RJR


80
81
82
83
# File 'lib/manufactured/rjr/loot.rb', line 80

def dispatch_manufactured_rjr_loot(dispatcher)
  m = Manufactured::RJR::LOOT_METHODS
  dispatcher.handle 'manufactured::collect_loot', &m[:collect_loot]
end

#dispatch_manufactured_rjr_mining(dispatcher) ⇒ Object

module Manufactured::RJR


41
42
43
44
45
# File 'lib/manufactured/rjr/mining.rb', line 41

def dispatch_manufactured_rjr_mining(dispatcher)
  m = Manufactured::RJR::MINING_METHODS
  dispatcher.handle 'manufactured::start_mining', &m[:start_mining]
  # dispatcher.handle('manufactured::stop_mining', 'TODO')
end

#dispatch_manufactured_rjr_move(dispatcher) ⇒ Object


58
59
60
61
# File 'lib/manufactured/rjr/move.rb', line 58

def dispatch_manufactured_rjr_move(dispatcher)
  m = Manufactured::RJR::MOVE_METHODS
  dispatcher.handle 'manufactured::move_entity', &m[:move_entity]
end

#dispatch_manufactured_rjr_remove_callbacks(dispatcher) ⇒ Object

module Manufactured::RJR


49
50
51
52
53
54
# File 'lib/manufactured/rjr/remove_callbacks.rb', line 49

def dispatch_manufactured_rjr_remove_callbacks(dispatcher)
  m = Manufactured::RJR::REMOVE_CALLBACKS_METHODS
  dispatcher.handle ['manufactured::remove_callbacks',
                     'manufactured::unsubscribe'],
                  &m[:remove_callbacks]
end

#dispatch_manufactured_rjr_resources(dispatcher) ⇒ Object

module Manufactured::RJR


120
121
122
123
124
# File 'lib/manufactured/rjr/resources.rb', line 120

def dispatch_manufactured_rjr_resources(dispatcher)
  m = Manufactured::RJR::RESOURCES_METHODS
  dispatcher.handle 'manufactured::add_resource',      &m[:add_resource]
  dispatcher.handle 'manufactured::transfer_resource', &m[:transfer_resource]
end

#dispatch_manufactured_rjr_state(dispatcher) ⇒ Object


27
28
29
30
31
# File 'lib/manufactured/rjr/state.rb', line 27

def dispatch_manufactured_rjr_state(dispatcher)
  m = Manufactured::RJR::STATE_METHODS
  dispatcher.handle "manufactured::save_state",    &m[:save_state]
  dispatcher.handle "manufactured::restore_state", &m[:restore_state]
end

#dispatch_manufactured_rjr_stop(dispatcher) ⇒ Object


36
37
38
39
# File 'lib/manufactured/rjr/stop.rb', line 36

def dispatch_manufactured_rjr_stop(dispatcher)
  m = Manufactured::RJR::STOP_METHODS
  dispatcher.handle 'manufactured::stop_entity', &m[:stop_entity]
end

#dispatch_manufactured_rjr_subscribe_to(dispatcher) ⇒ Object

module Manufactured::RJR


62
63
64
65
66
# File 'lib/manufactured/rjr/subscribe_to.rb', line 62

def dispatch_manufactured_rjr_subscribe_to(dispatcher)
  m = Manufactured::RJR::SUBSCRIBE_TO_METHODS
  dispatcher.handle 'manufactured::subscribe_to',
                 &m[:subscribe_to]
end

#dispatch_missions_rjr_assign(dispatcher) ⇒ Object


83
84
85
86
87
# File 'lib/missions/rjr/assign.rb', line 83

def dispatch_missions_rjr_assign(dispatcher)
  m = Missions::RJR::ASSIGN_METHODS
  dispatcher.handle 'missions::assign_mission', &m[:assign_mission]
  #dispatcher.handle('missions::unassign_mission', '...' # TODO ?
end

#dispatch_missions_rjr_create(dispatcher) ⇒ Object

module Missions::RJR


64
65
66
67
68
# File 'lib/missions/rjr/create.rb', line 64

def dispatch_missions_rjr_create(dispatcher)
  m = Missions::RJR::CREATE_METHODS
  dispatcher.handle 'missions::create_event',   &m[:create_event]
  dispatcher.handle 'missions::create_mission', &m[:create_mission]
end

#dispatch_missions_rjr_events(dispatcher) ⇒ Object


100
101
102
103
104
# File 'lib/missions/rjr/events.rb', line 100

def dispatch_missions_rjr_events(dispatcher)
  m = Missions::RJR::EVENTS_METHODS
  dispatcher.handle 'missions::subscribe_to',     &m[:subscribe_to]
  dispatcher.handle 'missions::unsubscribe',       &m[:unsubscribe]
end

#dispatch_missions_rjr_get(dispatcher) ⇒ Object

module Missions::RJR


41
42
43
44
45
# File 'lib/missions/rjr/get.rb', line 41

def dispatch_missions_rjr_get(dispatcher)
  m = Missions::RJR::GET_METHODS
  dispatcher.handle ['missions::get_missions', 'missions::get_mission'],
                                                       &m[:get_missions]
end

#dispatch_missions_rjr_hooks(dispatcher) ⇒ Object

module Missions::RJR


37
38
39
40
# File 'lib/missions/rjr/hooks.rb', line 37

def dispatch_missions_rjr_hooks(dispatcher)
  m = Missions::RJR::HOOKS_METHODS
  dispatcher.handle 'missions::add_hook', &m[:add_hook]
end

#dispatch_missions_rjr_init(dispatcher) ⇒ Object

Dispatch init


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/missions/rjr/init.rb', line 119

def dispatch_missions_rjr_init(dispatcher)
  Missions::RJR.registry.start

  # setup Missions::RJR module
  rjr = Object.new.extend(Missions::RJR)
  rjr.node.dispatcher = dispatcher
  rjr.node.dispatcher.env /missions::.*/, Missions::RJR
  rjr.node.dispatcher.add_module('missions/rjr/create')
  rjr.node.dispatcher.add_module('missions/rjr/get')
  rjr.node.dispatcher.add_module('missions/rjr/assign')
  rjr.node.dispatcher.add_module('missions/rjr/hooks')
  rjr.node.dispatcher.add_module('missions/rjr/events')
  rjr.node.dispatcher.add_module('missions/rjr/state')
  rjr.node.message_headers['source_node'] = 'missions'

  # create missions user
  begin rjr.node.invoke('users::create_user', rjr.user)
  rescue Exception => e ; end

  # grant missions user extra permissions
  # all in all missions is a pretty powerful role/user in terms
  #  of what it can do w/ the simulation
  role_id = "user_role_#{rjr.user.id}"
  Missions::RJR::PRIVILEGES.each { |p,e|
     rjr.node.invoke('users::add_privilege', role_id, p, e)
   }

  # log the missions user in
  session = rjr.node.invoke('users::login', rjr.user)
  rjr.node.message_headers['session_id'] = session.id

  # add callback for manufactured events, override environment it runs in
  m = Missions::RJR::CALLBACK_METHODS
  rjr.node.dispatcher.handle('manufactured::event_occurred', &m[:manufactured_event])
  rjr.node.dispatcher.env 'manufactured::event_occurred', Missions::RJR

  # add callback for users events, subscribe to registered_user event
  rjr.node.dispatcher.handle('users::event_occurred', &m[:users_event])
  rjr.node.dispatcher.env 'users::event_occurred', Missions::RJR
  rjr.node.invoke('users::subscribe_to', 'registered_user')
end

#dispatch_missions_rjr_inspect(dispatcher) ⇒ Object


33
34
35
36
# File 'lib/missions/rjr/inspect.rb', line 33

def dispatch_missions_rjr_inspect(dispatcher)
  m = Missions::RJR::INSPECT_METHODS
  dispatcher.handle "missions::status", &m[:get_status]
end

#dispatch_missions_rjr_state(dispatcher) ⇒ Object


26
27
28
29
30
# File 'lib/missions/rjr/state.rb', line 26

def dispatch_missions_rjr_state(dispatcher)
  m = Missions::RJR::STATE_METHODS
  dispatcher.handle "missions::save_state",    &m[:save_state]
  dispatcher.handle "missions::restore_state", &m[:restore_state]
end

#dispatch_motel_rjr_create(dispatcher) ⇒ Object


39
40
41
42
# File 'lib/motel/rjr/create.rb', line 39

def dispatch_motel_rjr_create(dispatcher)
  m = Motel::RJR::CREATE_METHODS
  dispatcher.handle 'motel::create_location', &m[:create_location]
end

#dispatch_motel_rjr_delete(dispatcher) ⇒ Object


31
32
33
34
# File 'lib/motel/rjr/delete.rb', line 31

def dispatch_motel_rjr_delete(dispatcher)
  m = Motel::RJR::DELETE_METHODS
  dispatcher.handle 'motel::delete_location', &m[:delete_location]
end

#dispatch_motel_rjr_get(dispatcher) ⇒ Object


83
84
85
86
87
# File 'lib/motel/rjr/get.rb', line 83

def dispatch_motel_rjr_get(dispatcher)
  m = Motel::RJR::GET_METHODS
  dispatcher.handle ['motel::get_location', 'motel::get_locations'],
                                                  &m[:get_location]
end

#dispatch_motel_rjr_init(dispatcher) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/motel/rjr/init.rb', line 38

def dispatch_motel_rjr_init(dispatcher)
  Motel::RJR.registry.start

  # run motel method handlers in motel::rjr module
  dispatcher.env /motel::.*/, Motel::RJR
  dispatcher.add_module('motel/rjr/create')
  dispatcher.add_module('motel/rjr/get')
  dispatcher.add_module('motel/rjr/update')
  dispatcher.add_module('motel/rjr/delete')
  dispatcher.add_module('motel/rjr/track')
  dispatcher.add_module('motel/rjr/state')
end

#dispatch_motel_rjr_inspect(dispatcher) ⇒ Object


36
37
38
39
# File 'lib/motel/rjr/inspect.rb', line 36

def dispatch_motel_rjr_inspect(dispatcher)
  m = Motel::RJR::INSPECT_METHODS
  dispatcher.handle "motel::status", &m[:get_status]
end

#dispatch_motel_rjr_state(dispatcher) ⇒ Object


25
26
27
28
29
# File 'lib/motel/rjr/state.rb', line 25

def dispatch_motel_rjr_state(dispatcher)
  m = Motel::RJR::STATE_METHODS
  dispatcher.handle "motel::save_state",    &m[:save_state]
  dispatcher.handle "motel::restore_state", &m[:restore_state]
end

#dispatch_motel_rjr_track(dispatcher) ⇒ Object


211
212
213
214
215
216
217
218
219
220
# File 'lib/motel/rjr/track.rb', line 211

def dispatch_motel_rjr_track(dispatcher)
  m = Motel::RJR::TRACK_METHODS
  track_methods =
    ['motel::track_movement',  'motel::track_rotation',
     'motel::track_proximity', 'motel::track_stops',
     'motel::track_strategy']

  dispatcher.handle track_methods, &m[:track_handler]
  dispatcher.handle 'motel::remove_callbacks', &m[:remove_callbacks]
end

#dispatch_motel_rjr_update(dispatcher) ⇒ Object


42
43
44
45
# File 'lib/motel/rjr/update.rb', line 42

def dispatch_motel_rjr_update(dispatcher)
  m = Motel::RJR::UPDATE_METHODS
  dispatcher.handle "motel::update_location", &m[:update_location]
end

#dispatch_stats_rjr_get(dispatcher) ⇒ Object


31
32
33
34
# File 'lib/stats/rjr/get.rb', line 31

def dispatch_stats_rjr_get(dispatcher)
  m = Stats::RJR::GET_METHODS
  dispatcher.handle 'stats::get', &m[:get_stats]
end

#dispatch_stats_rjr_init(dispatcher) ⇒ Object


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/stats/rjr/init.rb', line 77

def dispatch_stats_rjr_init(dispatcher)
  # setup Stats::RJR module
  rjr = Object.new.extend(Stats::RJR)
  rjr.node.dispatcher = dispatcher
  rjr.node.dispatcher.env /stats::.*/, Stats::RJR
  rjr.node.dispatcher.add_module('stats/rjr/get')
  rjr.node.message_headers['source_node'] = 'stats'

  begin rjr.node.invoke('users::create_user', rjr.user)
  rescue Exception => e ; end

  # grant stats user extra permissions
  role_id = "user_role_#{rjr.user.id}"
  Stats::RJR::PRIVILEGES.each { |p,e|
     rjr.node.invoke('users::add_privilege', role_id, p, e)
   }

  session = rjr.node.invoke('users::login', rjr.user)
  rjr.node.message_headers['session_id'] = session.id
end

#dispatch_stats_rjr_inspect(dispatcher) ⇒ Object

TODO

  • # of times stats retrieved


11
12
13
14
15
16
# File 'lib/stats/rjr/inspect.rb', line 11

def dispatch_stats_rjr_inspect(dispatcher)
  #dispatcher.handle "stats::status" do
  #  {
  #  }
  #end
end

#dispatch_users_rjr_attribute(dispatcher) ⇒ Object

module Users::RJR


73
74
75
76
77
78
79
80
# File 'lib/users/rjr/attribute.rb', line 73

def dispatch_users_rjr_attribute(dispatcher)
  m = Users::RJR::ATTRIBUTE_METHODS
  dispatcher.handle 'users::update_attribute', &m[:update_attribute]
  dispatcher.handle 'users::has_attribute?',   &m[:has_attribute]

  # TODO allow client to subscribe to attribute changes
  # dispatcher.handle('users::subscribe_to_progression') ...
end

#dispatch_users_rjr_create(dispatcher) ⇒ Object

module Users::RJR


86
87
88
89
90
# File 'lib/users/rjr/create.rb', line 86

def dispatch_users_rjr_create(dispatcher)
  m = Users::RJR::CREATE_METHODS
  dispatcher.handle 'users::create_user', &m[:create_user]
  dispatcher.handle 'users::create_role', &m[:create_role]
end

#dispatch_users_rjr_events(dispatcher) ⇒ Object


94
95
96
97
98
# File 'lib/users/rjr/events.rb', line 94

def dispatch_users_rjr_events(dispatcher)
  m = Users::RJR::EVENTS_METHODS
  dispatcher.handle 'users::subscribe_to',     &m[:subscribe_to]
  dispatcher.handle 'users::unsubscribe',       &m[:unsubscribe]
end

#dispatch_users_rjr_get(dispatcher) ⇒ Object

module Users::RJR


52
53
54
55
56
# File 'lib/users/rjr/get.rb', line 52

def dispatch_users_rjr_get(dispatcher)
  m = Users::RJR::GET_METHODS
  dispatcher.handle ['users::get_entity', 'users::get_entities'],
                                               &m[:get_entities]
end

#dispatch_users_rjr_init(dispatcher) ⇒ Object

module Users::RJR


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/users/rjr/init.rb', line 101

def dispatch_users_rjr_init(dispatcher)
  Users::RJR.registry.start

  # init defaults
  Users::RJR.permenant_users ||= []

  # setup Users::RJR module
  rjr = Object.new.extend(Users::RJR)
  rjr.node.dispatcher = dispatcher
  rjr.node.dispatcher.env /users::.*/, Users::RJR
  rjr.node.dispatcher.add_module('users/rjr/create')
  rjr.node.dispatcher.add_module('users/rjr/get')
  rjr.node.dispatcher.add_module('users/rjr/update')
  rjr.node.dispatcher.add_module('users/rjr/permissions')
  rjr.node.dispatcher.add_module('users/rjr/register')
  rjr.node.dispatcher.add_module('users/rjr/session')
  rjr.node.dispatcher.add_module('users/rjr/attribute')
  rjr.node.dispatcher.add_module('users/rjr/events')
  rjr.node.dispatcher.add_module('users/rjr/state')
  rjr.node.message_headers['source_node'] = 'users'

  # ignore err if user already created
  begin rjr.node.invoke('users::create_user', rjr.user)
  rescue Exception => e ; end

  session = rjr.node.invoke('users::login', rjr.user)
  rjr.node.message_headers['session_id'] = session.id

  # create configured users w/ configured permissions
  Users::RJR::additional_users.each { |user|
    nuser = Users::User.new :id => user[:user_id],
                            :password => user[:password],
                            :registration_code => nil
    begin rjr.node.invoke('users::create_user', nuser)
    rescue Exception => e ; end

    role_id = "user_role_#{nuser.id}"
    user[:permissions].each { |permission_entity|
      permission = permission_entity.first
      entity     = permission_entity.size > 1 ? permission_entity[1] : nil
      if entity.nil?
        rjr.node.invoke('users::add_privilege', role_id, permission)
      else
        rjr.node.invoke('users::add_privilege', role_id, permission, entity)
      end
    } if user[:permissions]
  } if Users::RJR::additional_users
end

#dispatch_users_rjr_inspect(dispatcher) ⇒ Object


39
40
41
42
# File 'lib/users/rjr/inspect.rb', line 39

def dispatch_users_rjr_inspect(dispatcher)
  m = Users::RJR::INSPECT_METHODS
  dispatcher.handle "users::status", &m[:get_status]
end

#dispatch_users_rjr_permissions(dispatcher) ⇒ Object

module Users::RJR


119
120
121
122
123
124
125
126
127
# File 'lib/users/rjr/permissions.rb', line 119

def dispatch_users_rjr_permissions(dispatcher)
  m = Users::RJR::PERMISSION_METHODS

  dispatcher.handle 'users::add_role', &m[:add_role]
  dispatcher.handle 'users::remove_role', &m[:remove_role]

  dispatcher.handle 'users::add_privilege', &m[:add_privilege]
  dispatcher.handle 'users::remove_privilege', &m[:remove_privilege]
end

#dispatch_users_rjr_register(dispatcher) ⇒ Object

module Users::RJR


86
87
88
89
90
# File 'lib/users/rjr/register.rb', line 86

def dispatch_users_rjr_register(dispatcher)
  m = Users::RJR::REGISTER_METHODS
  dispatcher.handle 'users::register',         &m[:register]
  dispatcher.handle 'users::confirm_register', &m[:confirm_register]
end

#dispatch_users_rjr_session(dispatcher) ⇒ Object

module Users::RJR


68
69
70
71
72
# File 'lib/users/rjr/session.rb', line 68

def dispatch_users_rjr_session(dispatcher)
  m = Users::RJR::SESSION_METHODS
  dispatcher.handle 'users::login',  &m[:login]
  dispatcher.handle 'users::logout', &m[:logout]
end

#dispatch_users_rjr_state(dispatcher) ⇒ Object

module Users::RJR


25
26
27
28
29
# File 'lib/users/rjr/state.rb', line 25

def dispatch_users_rjr_state(dispatcher)
  m = Users::RJR::STATE_METHODS
  dispatcher.handle "users::save_state",    &m[:save_state]
  dispatcher.handle "users::restore_state", &m[:restore_state]
end

#dispatch_users_rjr_update(dispatcher) ⇒ Object

module Users::RJR


40
41
42
43
# File 'lib/users/rjr/update.rb', line 40

def dispatch_users_rjr_update(dispatcher)
  m = Users::RJR::UPDATE_METHODS
  dispatcher.handle 'users::update_user', &m[:update_user]
end