Jeokkarak is the korean version of hashis. In our case, Jeokkarak is used to support evolution-ready schemas and loosely coupled systems in the web.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Schema evolution

One of the main issues with service oriented architectures is the use of strong coupled schema definitions shared between clients and servers.

In order to provide forward-compatibility, clients should be able to accept formats that contain
new content, without breaking own their own.

Jeokkarak and Hashi makes the perfect couple for this task: given a hash (parsed from a xml file), Jeokkarak will either:

  • instantiate your rail’s ActiveRecord type and use its relations
  • instantiate your type and use pre-defined relations
  • create a pseudo-object backed on the hash

In any of those cases, Jeokkarak will let your server evolve their schema, without requiring you to add new fields to your type.

Jeokkarak (箸)

Jeokkarak (箸) is the korean version of hashis. In our case, Jeokkarak is used to support
evolution-ready schemas and loosely coupled systems in the web.
By creating your own class only with the attributes you require:

class Player
  attr_accessor :name

You can still parse the entire hash and set the fields that you know, and allow schema evolution
(and forward compatibility) so that the new fields are dynamically created in your object:

# using the existing field
hash = {"name" => "guilherme silveira"}
player = Player.from_hash(hash) == ("guilherme silveira")
# dinamically creating a field
hash = {"age" => 29}
player = Player.from_hash(hash)
player.age.should == 29


It’s a common task to simulate objects from hashes, but one has to remember using hash access format in order to access it. Hashi helps you by allowing direct access to its content:

	hash = { :team => {:players => [{:name=>"guilherme silveira"},{:name=>"jose donizetti"}]}}
	object = Hashi.to_object(hash)

What is Hashi?

The reality without Hashi

	hash = { :team => {:players => [{:name=>"guilherme silveira"},{:name=>"jose donizetti"}]}}
	puts hash[:team][:players][0][:name] # his name

The reality without Hashi, within Rails

Although the Ruby language provides an easy way to access hashes, it becomes easier if you use Rails with Matt Pulver’s code:

	class Team < ActiveRecord::Base
		has_many :players
	class Player < ActiveRecord::Base
		# create a migration with field name:string
	hash = { :team => {:players => [{:name=>"guilherme silveira"},{:name=>"jose donizetti"}]}}
	puts Team.from_xml(hash).players[0].name

How does it compare to Hashie?

Hashi actually does not create your attributes, instead it deals with method_missing invocations to
simulate those properties, never creating a copy of your hash.

Updated hash

You can access the original hash (updated if you have made any changes) by one of those two ways:

	hash = { :team => {:players => [{:name=>"guilherme silveira"},{:name=>"jose donizetti"}]}}
	object = Hashi.to_object(hash)[0].name = 'jose donizetti'
	# the original hash was modified!
	puts hash
	# you can extract the original hash if you wish
	puts object.hash



Jeokkarak supports schema evoluted relationships: newly created relationships will be treated as Hashi’s:

hash = {"player" => [{"name" => "guilherme silveira"}, {"name" => "caue guerra"}], "new_relation" => {"new_entry" => 20}}
team = Team.from_hash(hash)
team.new_relation.new_entry.should == 20

It also supports pre-existing relations through the use of has_child:

class Team
  has_child Player, :as => "player"

# will instantiate a Player type:
hash = {"player" => {"name" => "guilherme silveira"}}
team = Team.from_hash(hash)
team.player.class.should == Player

And finally, it supports rails’s ActiveRecord:

class Team < ActiveRecord::Base
  has_many :players

hash = {"players" => [{"name" => "guilherme silveira"}]}
team = Team.from_hash(hash)
team.players[0].class.should == Player



gem install gemcutter
gem tumble
gem install jeokkarak


Just add in your environment.rb the following line:

config.gem "jeokkarak", :source => ""

And then execute:

rake gems:install

or, if you prefer to install it as a plugin:

script/plugin install git://


If you are looking for or want to help, let us know at the mailing list:


Hashi was created and is maintained within Caelum: by

Projetct Founder

Active Commiters

  • Guilherme Silveira
  • Jose Donizetti


You can see its source code at: github

What’s new


  • Supports active record relationships
  • Supports jeokkarak relationships
  • Supports boolean invocations with ?
  • Non-existing fields will throw an exception



  • Copyright © 2009 Caelum –
  • All rights reserved.
  • Licensed under the Apache License, Version 2.0 (the “License”);
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an “AS IS” BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.