smart_model 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc
CHANGED
@@ -17,30 +17,35 @@ To your Gemfile and run
|
|
17
17
|
[sudo] bundle install
|
18
18
|
And everything is OK!
|
19
19
|
|
20
|
-
==
|
21
|
-
|
22
|
-
=== smart_model
|
23
|
-
rails g smart_model
|
24
|
-
that creates a initializer that defines the MongoMapper database
|
25
|
-
=== smart_model
|
20
|
+
== Generator
|
21
|
+
SmartModel gives you the smart_model generator:
|
26
22
|
rails g smart_model project name:string content:string created_at:date in_progress:done
|
27
|
-
That creates a model Project
|
23
|
+
That creates a model Project with the SmartModel::Base module included
|
28
24
|
|
29
25
|
== SmartModel::Base
|
30
|
-
Is a class with all the MongoMapper::Document methods,
|
31
|
-
===
|
32
|
-
To add a title columns to your project model, that keeps a string , you can just type this:
|
26
|
+
Is a class with all the MongoMapper::Document methods, and with SmartModel::Attributes and SmartModel::Relationships included
|
27
|
+
=== SmartModel::Attributes
|
28
|
+
It is responsible for handling the columns of yout database. To add a title columns to your project model, that keeps a string ,in example, you can just type this:
|
33
29
|
class Project
|
34
|
-
include SmartModel::
|
30
|
+
include SmartModel::Attributes # Load SmartModel
|
35
31
|
string :title , :required => true # Create title column ,that accept strings
|
36
32
|
end
|
37
33
|
Or if you have many columns with the same behaviour , you can just manage them just like this:
|
38
34
|
class Project
|
39
|
-
include SmartModel::
|
35
|
+
include SmartModel::Attributes
|
40
36
|
strings [:title , : content] , :required => true # Create :title and :content columns
|
41
37
|
end
|
42
38
|
The given methods are
|
43
39
|
string(s) , integer(s) , boolean(s) , array(s) , objectid(s) , date(s)
|
40
|
+
=== SmartModel::Relationships
|
41
|
+
It is responsible for making the belongs_to method also create de column in the database for the id
|
42
|
+
class Project
|
43
|
+
include SmartModel::Relationships
|
44
|
+
belongs_to :task
|
45
|
+
# however , if you call , in example
|
46
|
+
# string :title
|
47
|
+
# it will raise an error , because you didn't included the Attributes module
|
48
|
+
end
|
44
49
|
|
45
50
|
== TO-DO
|
46
51
|
create a scaffold generator
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Nathan Proen\xC3\xA7a"
|
@@ -80,9 +80,6 @@ files:
|
|
80
80
|
- lib/generators/smart_model/templates/test.rb
|
81
81
|
- lib/generators/smart_model/USAGE
|
82
82
|
- lib/generators/smart_model/smart_model_generator.rb
|
83
|
-
- lib/generators/smart_mongo/templates/initializer.rb
|
84
|
-
- lib/generators/smart_mongo/USAGE
|
85
|
-
- lib/generators/smart_mongo/smart_mongo_generator.rb
|
86
83
|
- lib/smart_model.rb
|
87
84
|
- lib/smart_model/attributes.rb
|
88
85
|
- lib/smart_model/relationships.rb
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class SmartMongoGenerator < Rails::Generators::Base
|
2
|
-
source_root File.expand_path('../templates', __FILE__)
|
3
|
-
argument :db_name , :type => :string , :default => "#{RAILS_ROOT.to_s.split('/').last}-#{Rails.env}"
|
4
|
-
def setup
|
5
|
-
template "initializer.rb" , "config/initializers/setup_mongo_db.rb"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|