From 7d4a9658c29cad526cfe5c952f71109e8eb304e7 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 3 Dec 2013 15:07:11 -0800 Subject: Some simplification of code. --- users/app/models/service_level.rb | 26 +++++++------------------- users/app/models/user.rb | 6 +++--- 2 files changed, 10 insertions(+), 22 deletions(-) (limited to 'users/app/models') diff --git a/users/app/models/service_level.rb b/users/app/models/service_level.rb index ac5244f..299aaf1 100644 --- a/users/app/models/service_level.rb +++ b/users/app/models/service_level.rb @@ -1,31 +1,19 @@ class ServiceLevel def initialize(attributes = {}) - @level = attributes[:level] || APP_CONFIG[:default_service_level] + @id = attributes[:id] || APP_CONFIG[:default_service_level] end - def level - @level + def self.authenticated_select_options + APP_CONFIG[:service_levels].map { |id,config_hash| [config_hash[:description], id] if config_hash[:name] != 'anonymous'}.compact end - def name - APP_CONFIG[:service_levels][@level][:name] + def id + @id end - def cert_prefix - APP_CONFIG[:service_levels][@level][:cert_prefix] - end - - def description - APP_CONFIG[:service_levels][@level][:description] - end - - def cost - APP_CONFIG[:service_levels][@level][:cost] - end - - def quota - APP_CONFIG[:service_levels][@level][:quota] + def config_hash + APP_CONFIG[:service_levels][@id] end end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index 621ff4e..720f5a9 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -102,12 +102,12 @@ class User < CouchRest::Model::Base def desired_service_level code = self.desired_service_level_code || APP_CONFIG[:default_service_level] - ServiceLevel.new({level: code}) + ServiceLevel.new({id: code}) end def effective_service_level - code = self.effective_service_level_code || self.desired_service_level.level - ServiceLevel.new({level: code}) + code = self.effective_service_level_code || self.desired_service_level.id + ServiceLevel.new({id: code}) end protected -- cgit v1.2.3