Class: Megam::Space

Inherits:
Object
  • Object
show all
Defined in:
lib/megam/core/space.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpace

Returns a new instance of Space.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/megam/core/space.rb', line 19

def initialize()
  @id = nil
  @name = nil
  @description = nil
  @project = nil
  @wiki_name = nil
  @public_permissions = nil
  @team_permissions = nil
  @watcher_permissions = nil
  @share_permissions = nil
  @team_tab_role = nil
  @created_at = nil
  @updated_at = nil
  @default_showpage = nil
  @tabs_order = nil
  @parent_id = nil
  @restricted = nil
  @restricted_date = nil
  @commercial_from = nil
  @banner = nil
  @banner_height = nil
  @banner_text = nil
  @banner_link = nil
  @style = nil
  @status = nil
  @approved = nil
  @is_manager = nil
  @is_volunteer = nil
  @is_commercial = nil
  @can_join = nil
  @can_apply = nil
  @last_payer_changed_at = nil
end

Class Method Details

.createObject



488
489
490
491
# File 'lib/megam/core/space.rb', line 488

def self.create()
  acct = from_hash()
  acct.create
end

.from_hash(o) ⇒ Object



447
448
449
450
451
# File 'lib/megam/core/space.rb', line 447

def self.from_hash(o)
  space = self.new
  space.from_hash(o)
  space
end

.json_create(o) ⇒ Object



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/megam/core/space.rb', line 404

def self.json_create(o)
  space = new
  space.id(o["id"]) if o.has_key?("id")
  space.name(o["name"]) if o.has_key?("name")
  space.description(o["description"]) if o.has_key?("description")
  space.project(o["project"]) if o.has_key?("project")
  space.wiki_name(o["wiki_name"]) if o.has_key?("wiki_name")
  space.public_permissions(o["public_permissions"]) if o.has_key?("public_permissions")
  space.team_permissions(o["team_permissions"]) if o.has_key?("team_permissions")
  space.watcher_permissions(o["watcher_permissions"]) if o.has_key?("watcher_permissions")
  space.share_permissions(o["share_permissions"]) if o.has_key?("share_permissions")
  space.team_tab_role(o["team_tab_role"]) if o.has_key?("team_tab_role")
  space.created_at(o["created_at"]) if o.has_key?("created_at")
  space.updated_at(o["updated_at"]) if o.has_key?("updated_at")
  space.default_showpage(o["default_showpage"]) if o.has_key?("default_showpage")
  space.tabs_order(o["tabs_order"]) if o.has_key?("tabs_order")
  space.parent_id(o["parent_id"]) if o.has_key?("parent_id")
  space.restricted(o["restricted"]) if o.has_key?("restricted")
  space.restricted_date(o["restricted_date"]) if o.has_key?("restricted_date")
  space.commercial_from(o["commercial_from"]) if o.has_key?("commercial_from")
  space.banner(o["banner"]) if o.has_key?("banner")
  space.banner_height(o["banner_height"]) if o.has_key?("banner_height")
  space.banner_text(o["banner_text"]) if o.has_key?("banner_text")
  space.banner_link(o["banner_link"]) if o.has_key?("banner_link")
  space.style(o["style"]) if o.has_key?("style")
  space.status(o["status"]) if o.has_key?("status")
  space.approved(o["approved"]) if o.has_key?("approved")
  space.is_manager(o["is_manager"]) if o.has_key?("is_manager")
  space.is_volunteer(o["is_volunteer"]) if o.has_key?("is_volunteer")
  space.is_commercial(o["is_commercial"]) if o.has_key?("is_commercial")
  space.can_join(o["can_join"]) if o.has_key?("can_join")
  space.can_apply(o["can_apply"]) if o.has_key?("can_apply")
  space.last_payer_changed_at(o["last_payer_changed_at"]) if o.has_key?("last_payer_changed_at")

  #success or error
  space.some_msg[:code] = o["code"] if o.has_key?("code")
  space.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
  space.some_msg[:msg]= o["msg"] if o.has_key?("msg")
  space.some_msg[:links] = o["links"] if o.has_key?("links")

  space
end

.list(access_token) ⇒ Object



493
494
495
496
497
498
499
500
501
# File 'lib/megam/core/space.rb', line 493

def self.list(access_token)
  puts  "-----------------------------Entry list"
  space = self.new
  puts "----------------------------create iniliaze"
  puts access_token
  ss = space.megam_rest.get_spaces(access_token)
  puts ss.inspect
  ss
end

Instance Method Details

#approved(arg = nil) ⇒ Object



254
255
256
257
258
259
260
# File 'lib/megam/core/space.rb', line 254

def approved(arg=nil)
  if arg != nil
    @approved = arg
  else
  @approved
  end
end


206
207
208
209
210
211
212
# File 'lib/megam/core/space.rb', line 206

def banner(arg=nil)
  if arg != nil
    @banner = arg
  else
  @banner
  end
end


214
215
216
217
218
219
220
# File 'lib/megam/core/space.rb', line 214

def banner_height(arg=nil)
  if arg != nil
    @banner_height = arg
  else
  @banner_height
  end
end


222
223
224
225
226
227
228
# File 'lib/megam/core/space.rb', line 222

def banner_link(arg=nil)
  if arg != nil
    @banner_link = arg
  else
  @banner_link
  end
end


230
231
232
233
234
235
236
# File 'lib/megam/core/space.rb', line 230

def banner_text(arg=nil)
  if arg != nil
    @banner_text = arg
  else
  @banner_text
  end
end

#can_apply(arg = nil) ⇒ Object



294
295
296
297
298
299
300
# File 'lib/megam/core/space.rb', line 294

def can_apply(arg=nil)
  if arg != nil
    @can_apply = arg
  else
  @can_apply
  end
end

#can_join(arg = nil) ⇒ Object



286
287
288
289
290
291
292
# File 'lib/megam/core/space.rb', line 286

def can_join(arg=nil)
  if arg != nil
    @can_join = arg
  else
  @can_join
  end
end

#commercial_from(arg = nil) ⇒ Object



198
199
200
201
202
203
204
# File 'lib/megam/core/space.rb', line 198

def commercial_from(arg=nil)
  if arg != nil
    @commercial_from = arg
  else
  @commercial_from
  end
end

#created_at(arg = nil) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/megam/core/space.rb', line 142

def created_at(arg=nil)
  if arg != nil
    @created_at = arg
  else
  @created_at
  end
end

#default_showpage(arg = nil) ⇒ Object



158
159
160
161
162
163
164
# File 'lib/megam/core/space.rb', line 158

def default_showpage(arg=nil)
  if arg != nil
    @default_showpage = arg
  else
  @default_showpage
  end
end

#description(arg = nil) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/megam/core/space.rb', line 78

def description(arg=nil)
  if arg != nil
    @description = arg
  else
  @description
  end
end

#error?Boolean

Returns:

  • (Boolean)


318
319
320
# File 'lib/megam/core/space.rb', line 318

def error?
  crocked  = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end

#for_jsonObject



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/megam/core/space.rb', line 367

def for_json
  result = {
    "id" => id,
    "name" => name,
    "description" => description,
    "project" => project,
    "wiki_name" => wiki_name,
    "public_permissions" => public_permissions,
    "team_permissions" => team_permissions,
    "watcher_permissions" => watcher_permissions,
    "share_permissions" => share_permissions,
    "team_tab_role" => team_tab_role,
    "created_at" => created_at,
    "updated_at" => updated_at,
    "default_showpage" => default_showpage,
    "tabs_order" => tabs_order,
    "parent_id" => parent_id,
    "restricted" => restricted,
    "restricted_date" => restricted_date,
    "commercial_from" => commercial_from,
    "banner" => banner,
    "banner_height" => banner_height,
    "banner_text" => banner_text,
    "banner_link" => banner_link,
    "style" => style,
    "status" => status,
    "approved" => approved,
    "is_manager" => is_manager,
    "is_volunteer" => is_volunteer,
    "is_commercial" => is_commercial,
    "can_join" => can_join,
    "can_apply" => can_apply,
    "last_payer_changed_at" => last_payer_changed_at
  }
  result
end

#from_hash(o) ⇒ Object



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/megam/core/space.rb', line 453

def from_hash(o)
  @id        = o["id"] if o.has_key?("id")
  @name    = o["name"] if o.has_key?("name")
  @description    = o["description"] if o.has_key?("description")
  @project    = o["project"] if o.has_key?("project")
  @wiki_name   = o["wiki_name"] if o.has_key?("wiki_name")
  @public_permissions   = o["public_permissions"] if o.has_key?("public_permissions")
  @team_permissions   = o["team_permissions"] if o.has_key?("team_permissions")
  @watcher_permissions   = o["watcher_permissions"] if o.has_key?("watcher_permissions")
  @share_permissions   = o["share_permissions"] if o.has_key?("share_permissions")
  @team_tab_role   = o["team_tab_role"] if o.has_key?("team_tab_role")
  @created_at        = o["created_at"] if o.has_key?("created_at")
  @updated_at       = o["updated_at"] if o.has_key?("updated_at")
  @default_showpage   = o["default_showpage"] if o.has_key?("default_showpage")
  @tabs_order    = o["tabs_order"] if o.has_key?("tabs_order")
  @parent_id    = o["parent_id"] if o.has_key?("parent_id")
  @restricted   = o["restricted"] if o.has_key?("restricted")
  @restricted_date   = o["restricted_date"] if o.has_key?("restricted_date")
  @commercial_from   = o["commercial_from"] if o.has_key?("commercial_from")
  @banner   = o["banner"] if o.has_key?("banner")
  @banner_height   = o["banner_height"] if o.has_key?("banner_height")
  @banner_text  = o["banner_text"] if o.has_key?("banner_text")
  @banner_link        = o["banner_link"] if o.has_key?("banner_link")
  @style       = o["style"] if o.has_key?("style")
  @status   = o["status"] if o.has_key?("status")
  @approved    = o["approved"] if o.has_key?("approved")
  @is_manager   = o["is_manager"] if o.has_key?("is_manager")
  @is_volunteer   = o["is_volunteer"] if o.has_key?("is_volunteer")
  @is_commercial   = o["is_commercial"] if o.has_key?("is_commercial")
  @can_join   = o["can_join"] if o.has_key?("can_join")
  @can_apply   = o["can_apply"] if o.has_key?("can_apply")
  @last_payer_changed_at   = o["last_payer_changed_at"] if o.has_key?("last_payer_changed_at")
  self
end

#id(arg = nil) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/megam/core/space.rb', line 62

def id(arg=nil)
  if arg != nil
    @id = arg
  else
  @id
  end
end

#is_commercial(arg = nil) ⇒ Object



278
279
280
281
282
283
284
# File 'lib/megam/core/space.rb', line 278

def is_commercial(arg=nil)
  if arg != nil
    @is_commercial = arg
  else
  @is_commercial
  end
end

#is_manager(arg = nil) ⇒ Object



262
263
264
265
266
267
268
# File 'lib/megam/core/space.rb', line 262

def is_manager(arg=nil)
  if arg != nil
    @is_manager = arg
  else
  @is_manager
  end
end

#is_volunteer(arg = nil) ⇒ Object



270
271
272
273
274
275
276
# File 'lib/megam/core/space.rb', line 270

def is_volunteer(arg=nil)
  if arg != nil
    @is_volunteer = arg
  else
  @is_volunteer
  end
end

#last_payer_changed_at(arg = nil) ⇒ Object



302
303
304
305
306
307
308
# File 'lib/megam/core/space.rb', line 302

def last_payer_changed_at(arg=nil)
  if arg != nil
    @last_payer_changed_at = arg
  else
  @last_payer_changed_at
  end
end

#megam_restObject



53
54
55
56
# File 'lib/megam/core/space.rb', line 53

def megam_rest
  puts "megam_rest entry"     
  Megam::Assembla.new
end

#name(arg = nil) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/megam/core/space.rb', line 70

def name(arg=nil)
  if arg != nil
    @name = arg
  else
  @name
  end
end

#parent_id(arg = nil) ⇒ Object



174
175
176
177
178
179
180
# File 'lib/megam/core/space.rb', line 174

def parent_id(arg=nil)
  if arg != nil
    @parent_id = arg
  else
  @parent_id
  end
end

#project(arg = nil) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/megam/core/space.rb', line 86

def project(arg=nil)
  if arg != nil
    @project = arg
  else
  @project
  end
end

#public_permissions(arg = nil) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/megam/core/space.rb', line 102

def public_permissions(arg=nil)
  if arg != nil
    @public_permissions = arg
  else
  @public_permissions
  end
end

#restricted(arg = nil) ⇒ Object



182
183
184
185
186
187
188
# File 'lib/megam/core/space.rb', line 182

def restricted(arg=nil)
  if arg != nil
    @restricted = arg
  else
  @restricted
  end
end

#restricted_date(arg = nil) ⇒ Object



190
191
192
193
194
195
196
# File 'lib/megam/core/space.rb', line 190

def restricted_date(arg=nil)
  if arg != nil
    @restricted_date = arg
  else
  @restricted_date
  end
end

#share_permissions(arg = nil) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/megam/core/space.rb', line 126

def share_permissions(arg=nil)
  if arg != nil
    @share_permissions = arg
  else
  @share_permissions
  end
end

#some_msg(arg = nil) ⇒ Object



310
311
312
313
314
315
316
# File 'lib/megam/core/space.rb', line 310

def some_msg(arg=nil)
  if arg != nil
    @some_msg = arg
  else
  @some_msg
  end
end

#spaceObject



58
59
60
# File 'lib/megam/core/space.rb', line 58

def space
  self
end

#status(arg = nil) ⇒ Object



246
247
248
249
250
251
252
# File 'lib/megam/core/space.rb', line 246

def status(arg=nil)
  if arg != nil
    @status = arg
  else
  @status
  end
end

#style(arg = nil) ⇒ Object



238
239
240
241
242
243
244
# File 'lib/megam/core/space.rb', line 238

def style(arg=nil)
  if arg != nil
    @style = arg
  else
  @style
  end
end

#tabs_order(arg = nil) ⇒ Object



166
167
168
169
170
171
172
# File 'lib/megam/core/space.rb', line 166

def tabs_order(arg=nil)
  if arg != nil
    @tabs_order = arg
  else
  @tabs_order
  end
end

#team_permissions(arg = nil) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/megam/core/space.rb', line 110

def team_permissions(arg=nil)
  if arg != nil
    @team_permissions = arg
  else
  @team_permissions
  end
end

#team_tab_role(arg = nil) ⇒ Object



134
135
136
137
138
139
140
# File 'lib/megam/core/space.rb', line 134

def team_tab_role(arg=nil)
  if arg != nil
    @team_tab_role = arg
  else
  @team_tab_role
  end
end

#to_hashObject

Transform the ruby obj -> to a Hash



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/megam/core/space.rb', line 323

def to_hash
  index_hash = Hash.new
  index_hash["json_claz"] = self.class.name

  index_hash["id"] = id
  index_hash["name"] = name
  index_hash["description"] = description
  index_hash["project"] = project
  index_hash["wiki_name"] = wiki_name
  index_hash["public_permissions"] = public_permissions
  index_hash["team_permissions"] = team_permissions
  index_hash["watcher_permissions"] = watcher_permissions
  index_hash["share_permissions"] = share_permissions
  index_hash["team_tab_role"] = team_tab_role
  index_hash["created_at"] = created_at
  index_hash["updated_at"] = updated_at
  index_hash["default_showpage"] = default_showpage
  index_hash["tabs_order"] = tabs_order
  index_hash["parent_id"] = parent_id
  index_hash["restricted"] = restricted
  index_hash["restricted_date"] = restricted_date
  index_hash["commercial_from"] = commercial_from
  index_hash["banner"] = banner
  index_hash["banner_height"] = banner_height
  index_hash["banner_text"] = banner_text
  index_hash["banner_link"] = banner_link
  index_hash["style"] = style
  index_hash["status"] = status
  index_hash["approved"] = approved
  index_hash["is_manager"] = is_manager
  index_hash["is_volunteer"] = is_volunteer
  index_hash["is_commercial"] = is_commercial
  index_hash["can_join"] = can_join
  index_hash["can_apply"] = can_apply
  index_hash["last_payer_changed_at"] = last_payer_changed_at
  index_hash
end

#to_json(*a) ⇒ Object

Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.



363
364
365
# File 'lib/megam/core/space.rb', line 363

def to_json(*a)
  for_json.to_json(*a)
end

#to_sObject



503
504
505
# File 'lib/megam/core/space.rb', line 503

def to_s
  Megam::Stuff.styled_hash(to_hash)  
end

#updated_at(arg = nil) ⇒ Object



150
151
152
153
154
155
156
# File 'lib/megam/core/space.rb', line 150

def updated_at(arg=nil)
  if arg != nil
    @updated_at = arg
  else
  @updated_at
  end
end

#watcher_permissions(arg = nil) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/megam/core/space.rb', line 118

def watcher_permissions(arg=nil)
  if arg != nil
    @watcher_permissions = arg
  else
  @watcher_permissions
  end
end

#wiki_name(arg = nil) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/megam/core/space.rb', line 94

def wiki_name(arg=nil)
  if arg != nil
    @wiki_name = arg
  else
  @wiki_name
  end
end