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 +7 -0
- data/README.md +27 -28
- data/lib/entity_map/included.rb +0 -2
- data/lib/entity_map/version.rb +1 -1
- metadata +5 -4
data/Changelog
ADDED
data/README.md
CHANGED
@@ -1,43 +1,45 @@
|
|
1
1
|
# EntityMap
|
2
2
|
|
3
|
-
The
|
4
|
-
unambiguous mapping of the (business) entities and the relationships between
|
5
|
-
|
6
|
-
|
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,
|
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
|
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
|
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
|
-
|
101
|
-
include
|
102
|
-
include ActiveRecord::FinderMethods
|
102
|
+
include ActiveRecord::Model
|
103
|
+
include EntityMap
|
103
104
|
end
|
104
105
|
|
105
106
|
class Parent
|
106
|
-
|
107
|
-
include
|
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
|
data/lib/entity_map/included.rb
CHANGED
data/lib/entity_map/version.rb
CHANGED
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.
|
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-
|
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: &
|
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: *
|
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
|