Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An experiment in using Core Data in a Ruby-ish way with RubyMotion

tree: 41940e9d3a

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

A naive example of a migratable RubyMotion/CoreData wrapper

This uses a DSL which is inspired by DataMapper, but also ActiveRecord. In addition, it uses MagicalRecord for many common tasks.

The following models define a schema that is immediatly available during development:

class Author < MotionData::ManagedObject
  hasMany :articles, :class => 'Article'

  property :name, String, :required => true
end

class Article < MotionData::ManagedObject
  belongsTo :author, :class => 'Author'

  property :title,     String,  :required => true
  property :body,      String,  :required => true
  property :published, Boolean, :default  => false
end

NOTE: the association macros don't actually do anything yet.

The Schema instance can dump this definition, which looks like:

Schema.defineVersion('1.0') do |s|

  s.addEntity do |e|
    e.name = 'Article'
    e.managedObjectClassName = 'Article'
    e.addProperty :published, Boolean, {:default=>false}
    e.addProperty :title, String, {:required=>true}
    e.addProperty :body, String, {:required=>true}
  end

  s.addEntity do |e|
    e.name = 'Author'
    e.managedObjectClassName = 'Author'
    e.addProperty :name, String, {:required=>true}
  end

end

As you can see it has a version, this is the app’s release version. These dumps would be created on each new release of the app and would then allow for easy migrations with code that can be found in @mdiep’s CoreDataInCode example.

Something went wrong with that request. Please try again.