From aa4fffad32a52d624d1b3e7486b77dfee14648a4 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 24 Jan 2016 01:14:14 +0100 Subject: [PATCH] Improved code layout. --- app/models/object_lookup.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/object_lookup.rb b/app/models/object_lookup.rb index b3e5ccebd..853a66891 100644 --- a/app/models/object_lookup.rb +++ b/app/models/object_lookup.rb @@ -3,34 +3,32 @@ class ObjectLookup < ApplicationModel @@cache_object = {} # rubocop:disable Style/ClassVars - def self.by_id( id ) + def self.by_id(id) # use cache return @@cache_object[ id ] if @@cache_object[ id ] # lookup - lookup = self.lookup( id: id ) + lookup = self.lookup(id: id) return if !lookup @@cache_object[ id ] = lookup.name lookup.name end - def self.by_name( name ) + def self.by_name(name) # use cache return @@cache_object[ name ] if @@cache_object[ name ] # lookup - lookup = self.lookup( name: name ) + lookup = self.lookup(name: name) if lookup @@cache_object[ name ] = lookup.id return lookup.id end # create - lookup = create( - name: name - ) + lookup = create(name: name) @@cache_object[ name ] = lookup.id lookup.id end