Class: Platform::Config

Inherits:
Object show all
Defined in:
lib/platform/config.rb

Class Method Summary collapse

Class Method Details

.admin_helpersObject



312
313
314
315
# File 'lib/platform/config.rb', line 312

def self.admin_helpers
  return [] unless site_info[:admin_helpers]
  @admin_helpers ||= site_info[:admin_helpers].collect{|helper| helper.to_sym}
end

.admin_layoutObject



275
276
277
# File 'lib/platform/config.rb', line 275

def self.admin_layout
  site_info[:admin_layout]
end

.admin_user?(user = current_user) ⇒ Boolean

Returns:

  • (Boolean)


424
425
426
427
428
429
# File 'lib/platform/config.rb', line 424

def self.admin_user?(user = current_user)
  user.send([:methods][:admin])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} admin flag: #{ex.to_s}")
  false
end

.after_filtersObject



327
328
329
330
# File 'lib/platform/config.rb', line 327

def self.after_filters
  return [] unless site_info[:after_filters]
  @after_filters ||= site_info[:after_filters].collect{|filter| filter.to_sym}
end

.apiObject



216
217
218
# File 'lib/platform/config.rb', line 216

def self.api
  config[:API]
end

.api_allow_public?Boolean

Returns:

  • (Boolean)


556
557
558
# File 'lib/platform/config.rb', line 556

def self.api_allow_public?
  api[:allow_public]
end

.api_base_urlObject



576
577
578
# File 'lib/platform/config.rb', line 576

def self.api_base_url
  api[:base_url]
end

.api_config_pathObject



540
541
542
# File 'lib/platform/config.rb', line 540

def self.api_config_path
  api[:config_path]
end

.api_cookies_enabled?Boolean

Returns:

  • (Boolean)


552
553
554
# File 'lib/platform/config.rb', line 552

def self.api_cookies_enabled?
  api[:cookies_enabled]
end

.api_default_versionObject



592
593
594
# File 'lib/platform/config.rb', line 592

def self.api_default_version
  api[:default_version]
end

.api_explorer_appObject



600
601
602
603
# File 'lib/platform/config.rb', line 600

def self.api_explorer_app
  return if api_explorer_app_id.blank?
  @api_explorer_app ||= Platform::Application.find_by_id(api_explorer_app_id)
end

.api_explorer_app?Boolean

Returns:

  • (Boolean)


605
606
607
# File 'lib/platform/config.rb', line 605

def self.api_explorer_app?
  !api_explorer_app_id.blank?
end

.api_explorer_app_idObject



596
597
598
# File 'lib/platform/config.rb', line 596

def self.api_explorer_app_id
  config[:api_explorer_app_id]
end

.api_explorer_groups(api_version = api_default_version) ⇒ Object



660
661
662
# File 'lib/platform/config.rb', line 660

def self.api_explorer_groups(api_version = api_default_version)
  api[:explorer_groups][api_version]
end

.api_logging_enabled?Boolean

Returns:

  • (Boolean)


544
545
546
# File 'lib/platform/config.rb', line 544

def self.api_logging_enabled?
  api[:logging_enabled]
end

.api_max_modelsObject



560
561
562
# File 'lib/platform/config.rb', line 560

def self.api_max_models
  api[:max_models]
end

.api_proxies_pathObject



609
610
611
# File 'lib/platform/config.rb', line 609

def self.api_proxies_path
  api[:proxies_path]
end

.api_reference(api_version = api_default_version) ⇒ Object

API References



627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
# File 'lib/platform/config.rb', line 627

def self.api_reference(api_version = api_default_version)
  @api_reference ||= begin
    ref = HashWithIndifferentAccess.new
    api_supported_versions.each do |version|
      ref[version] = {}
      path = "#{root}/#{api[:config_path]}/#{version}"
      files = Dir.glob("#{path}/*.yml")
      files.each do |file|
        ref[version].merge!(YAML.load_file(file))
      end
    end  
    ref.freeze
  end
  @api_reference[api_version]
end

.api_reference_by_path(api_version, path) ⇒ Object



643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/platform/config.rb', line 643

def self.api_reference_by_path(api_version,  path)
  @api_reference_by_path ||= {}
  @api_reference_by_path[api_version] ||= begin
    api = api_reference(api_version)
    by_path = {}
    api.each do |key, defs|
      by_path[defs["path"]] = api[key]
      (defs[:actions] || []).each do |act_key, acts|
        path = acts["path"] || "#{defs["path"]}/#{act_key}"
        by_path[path] = defs[:actions][act_key]
      end
    end
    by_path
  end
  @api_reference_by_path[api_version][path]
end

.api_request_limitObject



548
549
550
# File 'lib/platform/config.rb', line 548

def self.api_request_limit
  api[:request_limit]
end

.api_request_windowObject



564
565
566
# File 'lib/platform/config.rb', line 564

def self.api_request_window
  api[:request_window]
end

.api_schemeObject



580
581
582
# File 'lib/platform/config.rb', line 580

def self.api_scheme
  api[:scheme]
end

.api_supported_version_optionsObject



588
589
590
# File 'lib/platform/config.rb', line 588

def self.api_supported_version_options
  @api_supported_version_options ||= api[:supported_versions].collect{|v| ["v #{v}", v]}
end

.api_supported_versionsObject



584
585
586
# File 'lib/platform/config.rb', line 584

def self.api_supported_versions
  api[:supported_versions]
end

.api_token_lifetimeObject



568
569
570
# File 'lib/platform/config.rb', line 568

def self.api_token_lifetime
  api[:token_lifetime]
end

.before_filtersObject



322
323
324
325
# File 'lib/platform/config.rb', line 322

def self.before_filters
  return [] unless site_info[:before_filters]
  @before_filters ||= site_info[:before_filters].collect{|filter| filter.to_sym}
end

.cache_adapterObject



228
229
230
# File 'lib/platform/config.rb', line 228

def self.cache_adapter
  caching[:adapter]
end

.cache_storeObject



232
233
234
# File 'lib/platform/config.rb', line 232

def self.cache_store
  caching[:store]
end

.cache_versionObject



236
237
238
# File 'lib/platform/config.rb', line 236

def self.cache_version
  caching[:version]
end

.cachingObject

Config Sections



204
205
206
# File 'lib/platform/config.rb', line 204

def self.caching
  config[:caching]
end

.configObject



153
154
155
# File 'lib/platform/config.rb', line 153

def self.config
  @config ||= load_yml("/config/platform/config.yml")
end

.create_media(file) ⇒ Object



469
470
471
472
473
474
475
476
477
# File 'lib/platform/config.rb', line 469

def self.create_media(file)
  media = site_media_class.constantize.create
  media.send(site_media_write_method, file)
  media
rescue Exception => ex
  pp ex
  Platform::Logger.error("Failed to create media: #{ex.to_s}")
  nil
end

.current_applicationObject



41
42
43
# File 'lib/platform/config.rb', line 41

def self.current_application
  Thread.current[:platform_current_application]
end

.current_application=(app) ⇒ Object



45
46
47
# File 'lib/platform/config.rb', line 45

def self.current_application=(app)
  Thread.current[:platform_current_application] = app
end

.current_developerObject



37
38
39
# File 'lib/platform/config.rb', line 37

def self.current_developer
  Thread.current[:platform_current_developer] 
end

.current_userObject



33
34
35
# File 'lib/platform/config.rb', line 33

def self.current_user
  Thread.current[:platform_current_user]
end

.current_user_is_admin?Boolean

Returns:

  • (Boolean)


431
432
433
# File 'lib/platform/config.rb', line 431

def self.current_user_is_admin?
  admin_user?
end

.current_user_is_developer?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/platform/config.rb', line 49

def self.current_user_is_developer?
  Thread.current[:platform_current_developer] != nil
end

.current_user_is_guest?Boolean

Returns:

  • (Boolean)


443
444
445
# File 'lib/platform/config.rb', line 443

def self.current_user_is_guest?
  guest_user?
end

.current_user_methodObject



340
341
342
# File 'lib/platform/config.rb', line 340

def self.current_user_method
  [:current_user_method]
end

.default_app_iconObject



193
194
195
# File 'lib/platform/config.rb', line 193

def self.default_app_icon
  "/assets/platform/default_app_icon.gif"
end

.default_app_logoObject



197
198
199
# File 'lib/platform/config.rb', line 197

def self.
  "/assets/platform/default_app_logo.gif"
end

.default_applicationsObject



130
131
132
# File 'lib/platform/config.rb', line 130

def self.default_applications
  @default_applications ||= load_yml("/config/platform/data/default_applications.yml")
end

.default_categoriesObject



134
135
136
# File 'lib/platform/config.rb', line 134

def self.default_categories
  @default_categories ||= load_yml("/config/platform/data/default_categories.yml")
end

.default_urlObject



267
268
269
# File 'lib/platform/config.rb', line 267

def self.default_url
  site_info[:default_url]
end

.developer_agreement_pathObject



181
182
183
# File 'lib/platform/config.rb', line 181

def self.developer_agreement_path
  config[:developer_agreement_path]
end

.disabled?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/platform/config.rb', line 161

def self.disabled?
  not enabled?
end

.enable_api?Boolean

API

Returns:

  • (Boolean)


536
537
538
# File 'lib/platform/config.rb', line 536

def self.enable_api?
  api[:enabled]
end

.enable_api_verification?Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/platform/config.rb', line 189

def self.enable_api_verification?
  config[:enable_api_verification]
end

.enable_app_directory?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/platform/config.rb', line 165

def self.enable_app_directory?
  config[:enable_app_directory]
end

.enable_app_statistics?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/platform/config.rb', line 185

def self.enable_app_statistics?
  config[:enable_app_statistics]
end

.enable_caching?Boolean

Caching

Returns:

  • (Boolean)


224
225
226
# File 'lib/platform/config.rb', line 224

def self.enable_caching?
  caching[:enabled]
end

.enable_developer_agreement?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/platform/config.rb', line 177

def self.enable_developer_agreement?
  config[:enable_developer_agreement]
end

.enable_embedded_applications?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/platform/config.rb', line 169

def self.enable_embedded_applications?
  config[:enable_embedded_applications]
end

.enable_logger?Boolean

Logger

Returns:

  • (Boolean)


244
245
246
# File 'lib/platform/config.rb', line 244

def self.enable_logger?
  logger[:enabled]
end

.enable_mobile_applications?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/platform/config.rb', line 173

def self.enable_mobile_applications?
  config[:enable_mobile_applications]
end

.enabled?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/platform/config.rb', line 157

def self.enabled?
  config[:enable_platform] 
end

.envObject



142
143
144
# File 'lib/platform/config.rb', line 142

def self.env
  Rails.env
end

Application Directory

Returns:

  • (Boolean)


497
498
499
# File 'lib/platform/config.rb', line 497

def self.featured_apps_enabled?
  true
end


509
510
511
# File 'lib/platform/config.rb', line 509

def self.featured_apps_per_page
  2
end


505
506
507
# File 'lib/platform/config.rb', line 505

def self.featured_apps_per_row
  2
end


501
502
503
# File 'lib/platform/config.rb', line 501

def self.featured_apps_title
  "Featured Applications"
end

.featuresObject



670
671
672
673
674
675
676
677
678
679
680
# File 'lib/platform/config.rb', line 670

def self.features
  @features ||= begin
    defs = load_yml("/config/platform/site/features.yml")
    feats = []
    defs[:enabled_features].each do |key|
      defs[key][:key] = key
      feats << defs[key] 
    end
    feats
  end
end

.guest_user?(user = current_user) ⇒ Boolean

Returns:

  • (Boolean)


435
436
437
438
439
440
441
# File 'lib/platform/config.rb', line 435

def self.guest_user?(user = current_user)
  return true unless user
  user.send([:methods][:guest])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} guest flag: #{ex.to_s}")
  true
end

.helpersObject



307
308
309
310
# File 'lib/platform/config.rb', line 307

def self.helpers
  return [] unless site_info[:helpers]
  @tr8n_helpers ||= site_info[:helpers].collect{|helper| helper.to_sym}
end

.icon_url(media) ⇒ Object



486
487
488
489
490
491
# File 'lib/platform/config.rb', line 486

def self.icon_url(media)
  eval("media.#{site_media_info[:icon_url_method]}")
rescue Exception => ex
  Platform::Logger.error("Failed to fetch icon url: #{ex.to_s}")
  default_app_icon
end

.init(site_current_user, current_application = nil) ⇒ Object



27
28
29
30
31
# File 'lib/platform/config.rb', line 27

def self.init(site_current_user, current_application = nil)
  Thread.current[:platform_current_user] = site_current_user
  Thread.current[:platform_current_developer] = Platform::Developer.for(site_current_user)
  Thread.current[:platform_current_application] = current_application
end

.init_categories(parent, categories) ⇒ Object



123
124
125
126
127
128
# File 'lib/platform/config.rb', line 123

def self.init_categories(parent, categories) 
  categories.each do |keyword, info|
    cat = Platform::Category.create(:parent => parent, :keyword => keyword, :name => info[:name], :position => info[:position])
    init_categories(cat, info[:categories]) if info[:categories]
  end
end

.init_default_applicationsObject



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/platform/config.rb', line 105

def self.init_default_applications
  puts "Initializing default applications..."
  unless system_developer
    puts "Cannot initialize default application because system user id is not specified in the config."
    return
  end
  
  default_applications.each do |keyword, description|
    app = Platform::Application.create(description.merge(:developer => system_developer))
    puts "Initialized #{app.name}."
  end    
end

.init_default_categoriesObject



118
119
120
121
# File 'lib/platform/config.rb', line 118

def self.init_default_categories
  puts "Initializing default categories..."
  init_categories(Platform::Category.root, default_categories)
end

.load_proxiesObject



613
614
615
616
617
# File 'lib/platform/config.rb', line 613

def self.load_proxies
  Dir["#{root}/#{api_proxies_path}/*_proxy_*.rb"].each do |file|
    require_or_load file
  end
end

.load_yml(file_path, for_env = env) ⇒ Object



146
147
148
149
150
151
# File 'lib/platform/config.rb', line 146

def self.load_yml(file_path, for_env = env)
  yml_path = "#{root}#{file_path}"
  yml = YAML.load_file(yml_path)
  yml = yml['defaults'].rmerge(yml[for_env] || {}) unless for_env.nil?
  HashWithIndifferentAccess.new(yml)
end

.log_pathObject



248
249
250
# File 'lib/platform/config.rb', line 248

def self.log_path
  logger[:log_path]
end

.loggerObject



208
209
210
# File 'lib/platform/config.rb', line 208

def self.logger
  config[:logger]
end

.login_url(params = {}) ⇒ Object



348
349
350
# File 'lib/platform/config.rb', line 348

def self.(params = {})
  site_info[:login_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&') 
end

.logo_url(media) ⇒ Object



479
480
481
482
483
484
# File 'lib/platform/config.rb', line 479

def self.logo_url(media)
  eval("media.#{site_media_info[:logo_url_method]}")
rescue Exception => ex
  Platform::Logger.error("Failed to fetch logo url: #{ex.to_s}")
  
end

.logout_methodObject



344
345
346
# File 'lib/platform/config.rb', line 344

def self.logout_method
  [:logout_method]
end

.logout_url(params = {}) ⇒ Object



352
353
354
# File 'lib/platform/config.rb', line 352

def self.logout_url(params = {})
  site_info[:logout_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&') 
end

.media_directoryObject



299
300
301
# File 'lib/platform/config.rb', line 299

def self.media_directory
  site_info[:media_directory]
end

.media_pathObject



303
304
305
# File 'lib/platform/config.rb', line 303

def self.media_path
  "#{root}/public#{media_directory}"
end

.modelsObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/platform/config.rb', line 59

def self.models
  @models ||= begin 
    mdls = [
        Platform::ApplicationDeveloper, Platform::ApplicationPermission, Platform::ApplicationUser,
        Platform::ApplicationCategory, Platform::Category, 
        Platform::ForumMessage, Platform::ForumTopic,
        Platform::Permission, Platform::Rating,
        Platform::Developer, Platform::Application, 
        Platform::Oauth::OauthToken, Platform::Oauth::AccessToken, 
        Platform::Oauth::RequestToken, Platform::Oauth::RefreshToken,
        Platform::Media::Media, Platform::Media::Image,
        Platform::ApplicationLog, Platform::RollupLog, 
        Platform::ApplicationMetric, Platform::DailyApplicationMetric, 
        Platform::WeeklyApplicationMetric, Platform::MonthlyApplicationMetric, 
        Platform::TotalApplicationMetric, Platform::ApplicationUsageMetric,
        Platform::LoggedException
    ]
  
    if user_class_name == "Platform::PlatformUser" # used for stand-alone deployment only
      mdls << [Platform::PlatformUser, Platform::PlatformAdmin] 
    end  
  
    mdls.flatten
  end
end

.oauth_desktop_layoutObject



295
296
297
# File 'lib/platform/config.rb', line 295

def self.oauth_desktop_layout
  site_info[:oauth_desktop_layout]
end

.oauth_fluid_layoutObject



283
284
285
# File 'lib/platform/config.rb', line 283

def self.oauth_fluid_layout
  site_info[:oauth_fluid_layout]
end

.oauth_mobile_layoutObject



291
292
293
# File 'lib/platform/config.rb', line 291

def self.oauth_mobile_layout
  site_info[:oauth_mobile_layout]
end

.oauth_popup_layoutObject



287
288
289
# File 'lib/platform/config.rb', line 287

def self.oauth_popup_layout
  site_info[:oauth_popup_layout]
end

.oauth_web_layoutObject



279
280
281
# File 'lib/platform/config.rb', line 279

def self.oauth_web_layout
  site_info[:oauth_web_layout]
end

.proxiesObject



619
620
621
# File 'lib/platform/config.rb', line 619

def self.proxies
  @proxies ||= {}
end

.reset!Object



53
54
55
56
57
# File 'lib/platform/config.rb', line 53

def self.reset!
  Thread.current[:platform_current_user] = nil
  Thread.current[:platform_current_developer] = nil
  Thread.current[:platform_current_application] = nil
end

.reset_all!Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/platform/config.rb', line 85

def self.reset_all!
  models.each do |cls|
    puts ">> Resetting #{cls.name}..."
    cls.delete_all
  end

  init_default_categories

  puts "Done."
end

.rootObject



138
139
140
# File 'lib/platform/config.rb', line 138

def self.root
  Rails.root
end

.searched_apps_per_pageObject



529
530
531
# File 'lib/platform/config.rb', line 529

def self.searched_apps_per_page
  15
end

.searched_apps_titleObject



525
526
527
# File 'lib/platform/config.rb', line 525

def self.searched_apps_title
  "Search Results"
end

.silhouette_image(user = current_user) ⇒ Object



666
667
668
# File 'lib/platform/config.rb', line 666

def self.silhouette_image(user = current_user)
  "/assets/platform/photo_silhouette.gif"
end

.site_base_urlObject



263
264
265
# File 'lib/platform/config.rb', line 263

def self.site_base_url
  site_info[:base_url]
end

.site_infoObject



212
213
214
# File 'lib/platform/config.rb', line 212

def self.site_info
  config[:site_info]
end

.site_layoutObject



271
272
273
# File 'lib/platform/config.rb', line 271

def self.site_layout
  site_info[:platform_layout]
end

.site_logo_urlObject



259
260
261
# File 'lib/platform/config.rb', line 259

def self.site_logo_url
  site_info[:logo_url] 
end

.site_media_classObject



460
461
462
463
# File 'lib/platform/config.rb', line 460

def self.site_media_class
  return "Platform::Media::Image" unless site_media_enabled?
  site_media_info[:class_name]
end

.site_media_enabled?Boolean

Returns:

  • (Boolean)


456
457
458
# File 'lib/platform/config.rb', line 456

def self.site_media_enabled?
  site_media_info[:enabled]
end

.site_media_infoObject

site media info The following methods could be overloaded in the initializer



452
453
454
# File 'lib/platform/config.rb', line 452

def self.site_media_info
  site_info[:media_info]
end

.site_media_write_methodObject



465
466
467
# File 'lib/platform/config.rb', line 465

def self.site_media_write_method
  site_media_info[:write_method]
end

.site_titleObject

Site Info



255
256
257
# File 'lib/platform/config.rb', line 255

def self.site_title
  site_info[:title] 
end

.site_user_infoObject

site user info The following methods could be overloaded in the initializer



336
337
338
# File 'lib/platform/config.rb', line 336

def self.
  site_info[:user_info]
end

.site_user_info_disabled?Boolean

Returns:

  • (Boolean)


360
361
362
# File 'lib/platform/config.rb', line 360

def self.
  !
end

.site_user_info_enabled?Boolean

Returns:

  • (Boolean)


356
357
358
# File 'lib/platform/config.rb', line 356

def self.
  [:enabled].nil? ? true : [:enabled]
end

.skip_before_filtersObject



317
318
319
320
# File 'lib/platform/config.rb', line 317

def self.skip_before_filters
  return [] unless site_info[:skip_before_filters]
  @skip_before_filters ||= site_info[:skip_before_filters].collect{|filter| filter.to_sym}
end

.suggested_apps_per_pageObject



521
522
523
# File 'lib/platform/config.rb', line 521

def self.suggested_apps_per_page
  20
end

.suggested_apps_per_rowObject



517
518
519
# File 'lib/platform/config.rb', line 517

def self.suggested_apps_per_row
  5
end

.suggested_apps_titleObject



513
514
515
# File 'lib/platform/config.rb', line 513

def self.suggested_apps_title
  "Applications You May Like"
end

.system_developerObject



101
102
103
# File 'lib/platform/config.rb', line 101

def self.system_developer
  @system_developer ||= Platform::Developer.find_or_create(Platform::Config.system_user)
end

.system_userObject



96
97
98
99
# File 'lib/platform/config.rb', line 96

def self.system_user
  return nil unless site_info[:system_user_id]
  @system_user ||= user_class_name.constantize.find_by_id(site_info[:system_user_id])
end

.user_classObject



369
370
371
# File 'lib/platform/config.rb', line 369

def self.user_class
  user_class_name.constantize
end

.user_class_nameObject



364
365
366
367
# File 'lib/platform/config.rb', line 364

def self.user_class_name
  return [:class_name] if 
  "Platform::PlatformUser"  
end

.user_email(user = current_user) ⇒ Object



387
388
389
390
391
392
# File 'lib/platform/config.rb', line 387

def self.user_email(user = current_user)
  user.send([:methods][:email])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
  nil
end

.user_gender(user = current_user) ⇒ Object



394
395
396
397
398
399
# File 'lib/platform/config.rb', line 394

def self.user_gender(user = current_user)
  user.send([:methods][:gender])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
  "unknown"
end

.user_id(user = current_user) ⇒ Object



373
374
375
376
377
378
# File 'lib/platform/config.rb', line 373

def self.user_id(user = current_user)
  user.send([:methods][:id])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch user id: #{ex.to_s}")
  0
end


410
411
412
413
414
415
# File 'lib/platform/config.rb', line 410

def self.user_link(user = current_user)
  user.send([:methods][:link])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} link: #{ex.to_s}")
  "/tr8n"
end

.user_locale(user = current_user) ⇒ Object



417
418
419
420
421
422
# File 'lib/platform/config.rb', line 417

def self.user_locale(user = current_user)
  user.send([:methods][:locale])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} locale: #{ex.to_s}")
  default_locale
end

.user_mugshot(user = current_user) ⇒ Object



401
402
403
404
405
406
407
408
# File 'lib/platform/config.rb', line 401

def self.user_mugshot(user = current_user)
  mugshot_image = user.send([:methods][:mugshot])
  return silhouette_image(user) if mugshot_image.blank?
  mugshot_image
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} image: #{ex.to_s}")
  silhouette_image
end

.user_name(user = current_user) ⇒ Object



380
381
382
383
384
385
# File 'lib/platform/config.rb', line 380

def self.user_name(user = current_user)
  user.send([:methods][:name])
rescue Exception => ex
  Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
  "Unknown user"
end