medea 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.12
1
+ 0.2.13
data/lib/medea.rb CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  module Medea
3
3
  require 'medea/inheritable_attributes'
4
+ require 'medea/list_properties'
4
5
  require 'medea/jasonobject'
5
6
  require 'medea/jasondeferredquery'
6
7
  require 'medea/jasonlistproperty'
@@ -14,30 +14,7 @@ module Medea
14
14
  inheritable_attributes :owned
15
15
  @owned = false
16
16
 
17
- def create_member_list list_name, list_class, list_type
18
- list = {}
19
- list = self.class_variable_get :@@lists if self.class_variable_defined? :@@lists
20
- list[list_name] = [list_class, list_type]
21
- self.send(:class_variable_set, "@@lists", list)
22
-
23
-
24
- define_method(list_name) do
25
- #puts "Looking at the #{list_name.to_s} list, which is full of #{list_type.name}s"
26
- JasonListProperty.new self, list_name, list_class, list_type
27
- end
28
- end
29
-
30
- def has_many list_name, list_class
31
- create_member_list list_name, list_class, :reference
32
- end
33
-
34
- def owns_many list_name, list_class
35
- create_member_list list_name, list_class, :value
36
-
37
- #also modify the items in the list so that they know that they're owned
38
- #list_type.class_variable_set :@@owner, self
39
- list_class.owned = true
40
- end
17
+ include JasonObjectListProperties
41
18
 
42
19
  #end meta
43
20
 
@@ -0,0 +1,31 @@
1
+ module JasonObjectListProperties
2
+ def self.included(base)
3
+ base.extend(MetaListProperties)
4
+ end
5
+
6
+ module MetaListProperties
7
+ def create_member_list list_name, list_class, list_type
8
+ list = {}
9
+ list = self.class_variable_get :@@lists if self.class_variable_defined? :@@lists
10
+ list[list_name] = [list_class, list_type]
11
+ self.send(:class_variable_set, "@@lists", list)
12
+
13
+ define_method(list_name) do
14
+ #puts "Looking at the #{list_name.to_s} list, which is full of #{list_type.name}s"
15
+ Medea::JasonListProperty.new self, list_name, list_class, list_type
16
+ end
17
+ end
18
+
19
+ def has_many list_name, list_class
20
+ create_member_list list_name, list_class, :reference
21
+ end
22
+
23
+ def owns_many list_name, list_class
24
+ create_member_list list_name, list_class, :value
25
+
26
+ #also modify the items in the list so that they know that they're owned
27
+ #list_type.class_variable_set :@@owner, self
28
+ list_class.owned = true
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medea
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 12
10
- version: 0.2.12
9
+ - 13
10
+ version: 0.2.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Jensen
@@ -78,6 +78,7 @@ files:
78
78
  - lib/medea/jasondeferredquery.rb
79
79
  - lib/medea/jasonlistproperty.rb
80
80
  - lib/medea/jasonobject.rb
81
+ - lib/medea/list_properties.rb
81
82
  has_rdoc: true
82
83
  homepage: https://github.com/rob-linton/Medea
83
84
  licenses: []