Project

jason-orm

0.0
No commit activity in last 3 years
No release in over 3 years
A persistence framework based on json files.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

Jason (Json Persistence Framework) Code Climate

Introduction

It's only for demonstration purposes. If you want to use it in your application - feel free:

gem "jason-orm", :require => "jason"

It uses *.json files for persistence. One for each model (imagine as row).

Features

By now, Jason supports:

  • a persistence_layer
  • a simple relation (association) mapper

It's customizable:

Jason.setup do |config|

  config.persistence_path = "/Users/bob/jsons"

  config.restore_app      = MyOwn::RestoreApp

end

config.restore_app allows to use an own Class which handles restoring from .json files. If this is set, it replaces the integrated Encoding::PersistenceHandler::Restorable class.

The persistence layer

Usage of the persistence layer is widly known from other libraries.

By now, it supports the following datatypes:

  • Integer
  • String
  • Date
class Person

  include Jason::Persistence

  attribute :first_name,  String
  attribute :last_name,   String

end

person = Person.new(:first_name => "Michail", :last_name => "Bulgakov")
person.save

person.update_attributes(:first_name => "Sascha")

person.delete

Person.find("1223wer43")
Person.find_by_id("1223wer43")
Person.find_by_last_name("Bulgakov") #=> returns Array, it's kind of 'where'
Person.find_by_first_name("Michael")

The relation mapper

Usage of the relation mapper is also widly known from other libraries.

By now it supports:

  • belongs_to
  • has_many (work in progress)
class Person

  include Jason::Persistence
  include Jason::Relation

  attribute :first_name,  String
  attribute :last_name,   String  
  attribute :age,         Integer

  belongs_to :wife

end

class Wife

  include Jason::Persistence
  include Jason::Relation

  attribute :name,  String
end

person = Person.new(:first_name => "Michail", :last_name => "Bulgakov")

woman = Wife.new(:name => "Natascha Rutskovskaja")

person.wife = woman 
person.save

belongs_to takes also a second parameter which is a hash:

belongs_to :wife, :class => "Woman"

so different class (names) are assignable to the relation name.

TODO

Feature Status
Date DONE
has_many DONE
Custom data types TODO
deletable only if already saved DONE
code documentation Partly & TODO
Gemspec DONE

Last words

Author: Daniel Schmidt, 15/16/17. July 2012