<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/java/org/jruby/ribs/RubyInterceptor.java</filename>
    </added>
    <added>
      <filename>test/identity_map_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -146,7 +146,7 @@ module Ribs
         properties.set_property(key, value)
       end
       @configuration = Configuration.new.add_properties(properties)
-      @configuration.set_interceptor org.jruby.ribs.EntityNameInterceptor.new
+      @configuration.set_interceptor org.jruby.ribs.RubyInterceptor.new(self, (self.default? ? :default : self.name).to_s)
       @mappings = @configuration.create_mappings
       reset_session_factory!
     end</diff>
      <filename>lib/ribs/db.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,7 +34,13 @@ module Ribs
     attr_accessor :persistent_class
     # The Rib that defines all the mapping data
     attr_accessor :rib
+    # Should this object be saved in an identity map?
+    attr_accessor :identity_map
     
+    def identity_map?
+      self.identity_map
+    end
+
     # Return the property instance for the given +name+.
     def [](name)
       self.persistent_class.get_property(name.to_s) rescue nil
@@ -49,6 +55,16 @@ module Ribs
         h
       end
     end
+
+    # Return all the properties for this model.
+    def properties_and_identity
+      (self.persistent_class.property_iterator.to_a + [self.persistent_class.identifier_property]).inject({}) do |h, value|
+        if !value.respond_to?(:getRubyValue)
+          h[value.name] = value
+        end
+        h
+      end
+    end
   end
 
   # Contains the mapping data that gets created when calling the
@@ -62,7 +78,7 @@ module Ribs
     attr_reader :to_avoid
     # List of default values for columns
     attr_reader :default_values
-
+    
     # Initializes object
     def initialize
       @columns = { }
@@ -174,6 +190,7 @@ module Ribs
 
       rm = options[:metadata]
       Ribs::add_metadata_for(options[:db], on, rm)
+      rm.identity_map = options.key?(:identity_map) ? options[:identity_map] : true
 
       unless options[:from]
         options[:from] = R(on, options[:db] || :default)
@@ -185,7 +202,8 @@ module Ribs
       with_handle(options[:db] || :default) do |h|
         db = h.db
         m = h.meta_data
-        name = rib.table || table_name_for(on.name, m)
+
+        name = table_name_for((rib.table || on.name), m)
 
         tables = m.get_tables nil, nil, name.to_s, %w(TABLE VIEW ALIAS SYNONYM).to_java(:String)
         if tables.next
@@ -299,11 +317,11 @@ module Ribs
     # Tries to figure out if a table name should be in lower case or
     # upper case, and returns the table name based on that.
     def table_name_for(str, metadata)
-      str = str.gsub(/::/, '_')
+      str = str.to_s.gsub(/::/, '_')
       if metadata.stores_lower_case_identifiers
         str.downcase
       elsif metadata.stores_upper_case_identifiers
-        str.upcase!
+        str.upcase
       else
         str
       end</diff>
      <filename>lib/ribs/definition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,8 +51,8 @@ module Ribs
       end
 
       def define_accessors
-        self.metadata.properties.each do |name, _|
-          self.model.send :attr_accessor, name
+        self.metadata.properties_and_identity.each do |name, _|
+          self.model.send :attr_accessor, name.downcase
         end
       end
       </diff>
      <filename>lib/ribs/repository.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 require File.join(File.dirname(__FILE__), 'test_helper')
 
 class Artist
+  Ribs! :identity_map =&gt; false
   attr_accessor :id
   attr_accessor :name
 end</diff>
      <filename>test/artist_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,23 @@ class Person;end
 R(Person).define_accessors
 
 describe &quot;define_accessors&quot; do 
-  it &quot;should define id accessors&quot;
-  it &quot;should define given name accessors&quot;
-  it &quot;should define sur name accessors&quot;
+  it &quot;should define id accessors&quot; do 
+    Person.instance_methods.should include(&quot;id&quot;)
+    Person.instance_methods.should include(&quot;id=&quot;)
+  end
+
+  it &quot;should define given_name accessors&quot; do 
+    Person.instance_methods.should include(&quot;given_name&quot;)
+    Person.instance_methods.should include(&quot;given_name=&quot;)
+  end
+  
+  it &quot;should define sur_name accessors&quot; do 
+    Person.instance_methods.should include(&quot;sur_name&quot;)
+    Person.instance_methods.should include(&quot;sur_name=&quot;)
+  end
+
+  it &quot;should define age accessors&quot; do 
+    Person.instance_methods.should include(&quot;age&quot;)
+    Person.instance_methods.should include(&quot;age=&quot;)
+  end
 end</diff>
      <filename>test/define_accessors_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,37 @@ Ribs::define_model :Address do |rib|
 end
 
 describe &quot;define_model&quot; do 
-  it &quot;should create a class&quot;
-  it &quot;should create a mapping&quot;
-  it &quot;should create all the needed properties&quot;
+  it &quot;should create a class&quot; do 
+    Address.class.should == Class
+  end
+  
+  it &quot;should create all the needed properties&quot; do 
+    Address.instance_methods.should include(&quot;id&quot;)
+    Address.instance_methods.should include(&quot;id=&quot;)
+    Address.instance_methods.should include(&quot;street&quot;)
+    Address.instance_methods.should include(&quot;street=&quot;)
+    Address.instance_methods.should include(&quot;postal&quot;)
+    Address.instance_methods.should include(&quot;postal=&quot;)
+    Address.instance_methods.should include(&quot;zip_code&quot;)
+    Address.instance_methods.should include(&quot;zip_code=&quot;)
+    Address.instance_methods.should_not include(&quot;zip&quot;)
+    Address.instance_methods.should_not include(&quot;zip=&quot;)
+    Address.instance_methods.should include(&quot;country&quot;)
+    Address.instance_methods.should include(&quot;country=&quot;)
+  end
+  
+  it &quot;should be a working Ribs class&quot; do 
+    R(Address).create :id =&gt; 1, :street =&gt; &quot;foobar 42&quot;
+    all = R(Address).all
+    all.length.should == 1
+    all[0].id.should == 1
+    all[0].street.should == &quot;foobar 42&quot;
+    all[0].zip_code.should be_nil
+    R(Address).get(1).street.should == all[0].street
+    all[0].street = &quot;foobar 43&quot;
+    R(all[0]).save
+    R(Address).get(1).street.should == &quot;foobar 43&quot;
+    R(Address).destroy(1)
+    R(Address).all.should be_empty
+  end
 end</diff>
      <filename>test/define_model_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>src/java/org/jruby/ribs/EntityNameInterceptor.java</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>4b04e930467ba585c2a78d789426556a50c40703</id>
    </parent>
  </parents>
  <author>
    <name>Ola Bini</name>
    <email>ola.bini@gmail.com</email>
  </author>
  <url>http://github.com/olabini/ribs/commit/0b8ddb8aec64b54bb5c8f1380dd13da35919eded</url>
  <id>0b8ddb8aec64b54bb5c8f1380dd13da35919eded</id>
  <committed-date>2008-09-10T06:22:53-07:00</committed-date>
  <authored-date>2008-09-10T06:22:53-07:00</authored-date>
  <message>Add support for identity-map functionality.</message>
  <tree>65dc2ec90b10fbd7e94caafdb589cdffa8813158</tree>
  <committer>
    <name>Ola Bini</name>
    <email>ola.bini@gmail.com</email>
  </committer>
</commit>
