smart_model 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'mongo_mapper'
3
+
4
+ module SmartModel
5
+ module Attributes
6
+ def self.included(model)
7
+ model.send :include , MongoMapper::Document
8
+ %w(String Integer Boolean Array ObjectId Date Time).each do |name|
9
+ model.class_eval "
10
+ private
11
+ def self.#{name.downcase}(value , options = {})
12
+ key value , #{name}, options
13
+ end
14
+
15
+ def self.#{name.downcase.pluralize}(values , options = {})
16
+ values.each do |val|
17
+ key val , #{name} , options
18
+ end
19
+ end
20
+ "
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'mongo_mapper'
3
+
4
+ module SmartModel
5
+ module Relationships
6
+ def self.included(model)
7
+ model.send :include , MongoMapper::Document
8
+ model.class_eval "
9
+ def self.belongs_to(value)
10
+ key \"\#{value}_id\" , ObjectId
11
+ super value
12
+ end"
13
+ end
14
+ end
15
+ end
16
+
data/lib/smart_model.rb CHANGED
@@ -1,44 +1,11 @@
1
1
  require 'rubygems'
2
2
  require 'mongo_mapper'
3
+ require 'smart_model/relationships'
3
4
 
4
5
  module SmartModel
5
- module Attributes
6
- def self.included(model)
7
- model.send :include , MongoMapper::Document
8
- %w(String Integer Boolean Array ObjectId Date Time).each do |name|
9
- model.class_eval "
10
- private
11
- def self.#{name.downcase}(value , options = {})
12
- key value , #{name}, options
13
- end
14
-
15
- def self.#{name.downcase.pluralize}(values , options = {})
16
- values.each do |val|
17
- key val , #{name} , options
18
- end
19
- end
20
- "
21
- end
22
- end
23
- end
24
-
25
- module Relationships
26
- def self.included(model)
27
- model.send :include , MongoMapper::Document
28
- model.class_eval "
29
- def self.belongs_to(value)
30
- key \"\#{value}_id\" , ObjectId
31
- super value
32
- end"
33
- end
34
- end
35
-
36
6
  module Base
37
7
  def self.included(model)
38
- # include MongoMapper::Document
39
- model.send :include , MongoMapper::Document
40
- model.send :include , SmartModel::Attributes
41
- model.send :include , SmartModel::Relationships
8
+ model.send :include , MongoMapper::Document , SmartModel::Attributes , SmartModel::Relationships
42
9
  end
43
10
  end
44
11
  end
data/rails/init.rb CHANGED
@@ -1,3 +1,4 @@
1
- # Include hook code here
2
- require File.join(File.dirname(__FILE__), "..", "lib", "smart_model")
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "smart_model.rb")
2
+ require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "relationships")
3
+ require File.join(File.dirname(__FILE__), "..", "lib", "smart_model" , "attributes")
3
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Nathan Proen\xC3\xA7a"
@@ -81,6 +81,8 @@ files:
81
81
  - lib/generators/smart_model/USAGE
82
82
  - lib/generators/smart_model/smart_model_generator.rb
83
83
  - lib/smart_model.rb
84
+ - lib/smart_model/attributes.rb
85
+ - lib/smart_model/relationships.rb
84
86
  - test/smart_model_test.rb
85
87
  - test/test_helper.rb
86
88
  - rails/init.rb