entitymap 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog ADDED
@@ -0,0 +1,7 @@
1
+ 0.0.2: 2012-02-12
2
+
3
+ * Bug fix: the included added an entity attr_accessor to target object
4
+
5
+ 0.0.1: 2012-02-12
6
+
7
+ * Initial release (Entity created for objects for which EntityMap is included)
data/README.md CHANGED
@@ -1,43 +1,45 @@
1
1
  # EntityMap
2
2
 
3
- The concept is to have an in-memory entity-relationsip model that has unique and
4
- unambiguous mapping of the (business) entities and the relationships between them,
5
- but still closely linked to the SQL concept of a foreign key as unambiguous
6
- implementation of a relationship between tables).
3
+ The idea is to have an in-memory entity-relationsip model that has unique and
4
+ unambiguous mapping of the (business) entities and the relationships between
5
+ them. On the other hand, the lowest level will be limited to the simple concept
6
+ of a foreign key/pointer from one entity to another, as an unambiguous
7
+ implementation of an asymmetric relationship between two entities.
7
8
 
8
9
  In ActiveRecord, there is an IdentityMap being developed, but even with
9
10
  IdentityMap turned on, the belongs_to and has_many relationships between
10
11
  Parent and Child are not uniquely mapped to each_other. It is possible to
11
12
  have at the same time
12
13
 
13
- ``
14
+ ```ruby
14
15
  daisy.children # => [#<Child:0x9275fe8 @name="Peter">]
15
16
  peter.mother # => #<Mother:0x964c518 @name="Maria">
16
17
  ```
17
- If I am the child of Daisy, then she should be my mother, huh ...
18
+ If I am the child of Daisy, then she should be my mother, no?
18
19
 
19
20
  So, the focus is on unambiguous and easy use of the relationships
20
21
  in an ER model (Entity-Relationship model) where the reciprocity
21
- of the 2 directions of the relationship is guaranteed correct.
22
+ of the view on the 2 directions of the _same_ relationship is
23
+ guaranteed correct.
22
24
 
23
25
  Mapping this form of ER-model to a database as a persistence
24
- layer is a second priority, after establishing the correct
26
+ layer is a different aspect, after establishing the correct
25
27
  Entity and Relationship behavior.
26
28
 
27
29
  ## Feature wish list
28
30
 
29
- it "handles belongs_to - has_many atomically in 1 place"
30
- it "has identity_map for entities"
31
- it "can be persisted in 1 command"
32
- it "will check validations on _all_ entities before persisting"
33
- it "allows select list in a form to work cleverly"
34
- it "has 'live' scopes that are honored in memory"
35
- it "can be marshalled"
36
- it "works with a Plain Old Ruby Object"
37
- it "works with other ORMs (ActiveRecord, Sequel, Datamapper)"
38
- it "works with SimpleForm 2"
39
- it "works with JRuby"
40
- it "works in other languages (Java, ...) ?"
31
+ * it "handles belongs_to - has_many atomically in 1 place"
32
+ * it "has identity_map for entities"
33
+ * it "can be persisted in 1 command"
34
+ * it "will check validations on _all_ entities before persisting"
35
+ * it "allows select list in a form to work cleverly"
36
+ * it "has 'live' scopes that are honored in memory"
37
+ * it "can be marshalled"
38
+ * it "works with a Plain Old Ruby Object"
39
+ * it "works with other ORMs (ActiveRecord, Sequel, Datamapper)"
40
+ * it "works with SimpleForm 2"
41
+ * it "works with JRuby"
42
+ * it "works in other languages (Java, ...) ?"
41
43
 
42
44
  ## Usage Example
43
45
 
@@ -97,15 +99,13 @@ peter.father.father_of # => [#<Child:0x9275fe8 @name="Peter">, #<Child:0xa49e030
97
99
  # adding an implementation of persistence
98
100
 
99
101
  class Child
100
- # not sure if this is enough ActiveRecord
101
- include ActiveRecord::Persistence
102
- include ActiveRecord::FinderMethods
102
+ include ActiveRecord::Model
103
+ include EntityMap
103
104
  end
104
105
 
105
106
  class Parent
106
- # not sure if this is enough ActiveRecord
107
- include ActiveRecord::Persistence
108
- include ActiveRecord::FinderMethods
107
+ include ActiveRecord::Model
108
+ include EntityMap
109
109
  end
110
110
 
111
111
  EntityMap.save # => true #(O)
@@ -113,12 +113,11 @@ peter.id # => 1 #(P)
113
113
  jan.id # => 2
114
114
  new_peter = Child.find(1)
115
115
  peter.object_id == new_peter.object_id # => true #(Q)
116
- peter.ref == new_peter.ref # => true #(R)
117
116
  ```
118
117
 
119
118
  ## Example of the Parent-Child ambiguity in ActiveRecord (4.0.0.beta)
120
119
 
121
- ```
120
+ ```ruby
122
121
  peterv@ASUS:~/b/github/rails/rails/new_app$ cat app/models/*
123
122
  class Child < ActiveRecord::Base
124
123
  belongs_to :parent, :inverse_of => :children
@@ -1,7 +1,5 @@
1
1
  module EntityMap
2
2
 
3
- attr_accessor :entity
4
-
5
3
  def initialize
6
4
  entity = Entity.new(self, EntityGroup.single)
7
5
  super
@@ -1,3 +1,3 @@
1
1
  module EntityMap
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entitymap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000 Z
12
+ date: 2012-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &72628490 !ruby/object:Gem::Requirement
16
+ requirement: &82065520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *72628490
24
+ version_requirements: *82065520
25
25
  description: ! 'Mapping entities and relations atomically in memory during the
26
26
 
27
27
  processing of a business transaction.
@@ -37,6 +37,7 @@ extra_rdoc_files: []
37
37
  files:
38
38
  - .gitignore
39
39
  - .rspec
40
+ - Changelog
40
41
  - Gemfile
41
42
  - MIT-LICENSE
42
43
  - README.md