motion/cdq/context.rb
# Create a new context by type, setting upstream to the topmost context if available,
# or to the persistent store coordinator if not.  Return the context but do NOT push it
# onto the stack.
#
Create a new context by type, setting upstream to the topmost context if available,
or to the persistent store coordinator if not.  Return the context but do NOT push it
onto the stack.
Create a new context by type setting upstream to the topmost context if available or to the persistent store coordinator if not . Return the context but do NOT push it onto the stack .
def create(concurrency_type, options = {}, &block)
      @has_been_set_up = true
      case concurrency_type
      when :main
        context = NSManagedObjectContext.alloc.initWithConcurrencyType(NSMainQueueConcurrencyType)
      when :private_queue, :private
        context = NSManagedObjectContext.alloc.initWithConcurrencyType(NSPrivateQueueConcurrencyType)
      else
        context = NSManagedObjectContext.alloc.initWithConcurrencyType(concurrency_type)
      end
      if stack.empty?
        if @store_manager.invalid?
          raise "store coordinator not found. Cannot create the first context without one."
        else
          context.mergePolicy = NSMergePolicy.alloc.initWithMergeType(NSMergeByPropertyObjectTrumpMergePolicyType)
          context.performBlockAndWait ->{
            coordinator = @store_manager.current
            context.persistentStoreCoordinator = coordinator
            NSNotificationCenter.defaultCenter.addObserver(self, selector:"did_finish_import:", name:NSPersistentStoreDidImportUbiquitousContentChangesNotification, object:nil)
            @observed_context = context
          }
        end
      else
        context.parentContext = stack.last
      end
      if options[:named]
        if respond_to?(options[:named])
          raise "Cannot name a context '#{options[:named]}': conflicts with existing method"
        end
        self.class.send(:define_method, options[:named]) do
          context
        end
      end
      context
    end
def create ( concurrency_type , options = { } , & block ) @has_been_set_up = true case concurrency_type when :main context = NSManagedObjectContext . alloc . initWithConcurrencyType ( NSMainQueueConcurrencyType ) when :private_queue , :private context = NSManagedObjectContext . alloc . initWithConcurrencyType ( NSPrivateQueueConcurrencyType ) else context = NSManagedObjectContext . alloc . initWithConcurrencyType ( concurrency_type ) end if stack . empty? if @store_manager . invalid? raise "store coordinator not found. Cannot create the first context without one." else context . mergePolicy = NSMergePolicy . alloc . initWithMergeType ( NSMergeByPropertyObjectTrumpMergePolicyType ) context . performBlockAndWait -> { coordinator = @store_manager . current context . persistentStoreCoordinator = coordinator NSNotificationCenter . defaultCenter . addObserver ( self , selector : "did_finish_import:" , name : NSPersistentStoreDidImportUbiquitousContentChangesNotification , object : nil ) @observed_context = context } end else context . parentContext = stack . last end if options [ :named ] if respond_to? ( options [ :named ] ) raise "Cannot name a context '#{options[:named]}': conflicts with existing method" end self . class . send ( :define_method , options [ :named ] ) do context end end context end
Create a new context by type, setting upstream to the topmost context if available,
or to the persistent store coordinator if not.
Create a new context by type setting upstream to the topmost context if available or to the persistent store coordinator if not .
#Dispatch::Queue.main.async { #}
concurrency_type
<not_specific>
options
<not_specific>
block
<not_specific>