[macruby-changes] [5293] MacRuby/trunk/misc/xcode4-templates/Project Templates/Mac/ Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 22 23:03:46 PDT 2011


Revision: 5293
          http://trac.macosforge.org/projects/ruby/changeset/5293
Author:   mattaimonetti at gmail.com
Date:     2011-03-22 23:03:43 -0700 (Tue, 22 Mar 2011)
Log Message:
-----------
slight cleanup of the Core Data template

Modified Paths:
--------------
    MacRuby/trunk/misc/xcode4-templates/Project Templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist

Modified: MacRuby/trunk/misc/xcode4-templates/Project Templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist
===================================================================
--- MacRuby/trunk/misc/xcode4-templates/Project Templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist	2011-03-23 02:37:32 UTC (rev 5292)
+++ MacRuby/trunk/misc/xcode4-templates/Project Templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist	2011-03-23 06:03:43 UTC (rev 5293)
@@ -169,22 +169,22 @@
 # Creates if necessary and returns the managed object model for the application.
 #
 def managedObjectModel
-    if @managedObjectModel.nil?
+    unless @managedObjectModel
       model_url = NSBundle.mainBundle.URLForResource("___PACKAGENAMEASIDENTIFIER___", withExtension:"momd")
       @managedObjectModel = NSManagedObjectModel.alloc.initWithContentsOfURL(model_url)
-    else
-      @managedObjectModel
     end
+    
+    @managedObjectModel
 end
 
 #
 # Returns the persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. (The directory for the store is created, if necessary.)
 #
 def persistentStoreCoordinator
-    return @persistentStoreCoordinator unless @persistentStoreCoordinator.nil?
+    return @persistentStoreCoordinator if @persistentStoreCoordinator
 
     mom = self.managedObjectModel
-    if mom.nil?
+    unless mom
         puts "#{self.class} No model to generate a store from"
         return nil
     end
@@ -211,7 +211,6 @@
 
             NSApplication.sharedApplication.presentError(error)
             return nil
-        end
     end
 
     url = directory.URLByAppendingPathComponent("___PACKAGENAMEASIDENTIFIER___.storedata")
@@ -230,11 +229,10 @@
 # bound to the persistent store coordinator for the application.) 
 #
 def managedObjectContext
-    return @managedObjectContext unless @managedObjectContext.nil?
-
+    return @managedObjectContext if @managedObjectContext
     coordinator = self.persistentStoreCoordinator
 
-    if coordinator.nil?
+    unless coordinator
         dict = {
             NSLocalizedDescriptionKey => "Failed to initialize the store",
             NSLocalizedFailureReasonErrorKey => "There was an error building up the data file."
@@ -275,7 +273,7 @@
 def applicationShouldTerminate(sender)
     # Save changes in the application's managed object context before the application terminates.
 
-    return NSTerminateNow if @managedObjectContext.nil?
+    return NSTerminateNow unless @managedObjectContext
 
     unless self.managedObjectContext.commitEditing
         puts "%@ unable to commit editing to terminate" % self.class
@@ -288,9 +286,7 @@
     error = Pointer.new_with_type('@')
     unless self.managedObjectContext.save(error)
         # Customize this code block to include application-specific recovery steps.
-        if sender.presentError(error[0]) == true
-            return NSTerminateCancel
-        end
+        return NSTerminateCancel if sender.presentError(error[0])
 
         alert = NSAlert.alloc.init
         alert.messageText = "Could not save changes while quitting. Quit anyway?"
@@ -299,10 +295,7 @@
         alert.addButtonWithTitle "Cancel"
 
         answer = alert.runModal
-        if (answer == NSAlertAlternateReturn)
-            return NSTerminateCancel
-        end
-
+        return NSTerminateCancel if answer == NSAlertAlternateReturn
     end
 
     NSTerminateNow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110322/f908985f/attachment-0001.html>


More information about the macruby-changes mailing list