mongoid_class_for_collection 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mongoid_class_for_collection.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ Description
2
+ ===========
3
+
4
+ The responsible way to work with migrations in mongoid.
5
+
6
+ Synopsis
7
+ ========
8
+
9
+ TODO
10
+
11
+ ### How do I use it?
12
+
13
+ def self.up
14
+ book_model = mongoid_class_for_collection :books do
15
+ # The same as Book.all
16
+ books = all
17
+ end
18
+
19
+ # or save the class for use just like your real model
20
+ puts book_model.first.name
21
+ end
22
+ end
23
+
24
+ Authors
25
+ =======
26
+
27
+ * Shawn Anderson (shawn.anderson@atomicobject.com)
28
+ * Sivabudh Umpudh (siva@atomicobject.com)
29
+ * © 2011 [Atomic Object](http://www.atomicobject.com/)
30
+ * More Atomic Object [open source](http://www.atomicobject.com/pages/Software+Commons) projects
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ module MongoidClassForCollection
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+
2
+ module MongoidClassForCollection
3
+ def mongoid_class_for_collection collection, &blk
4
+ module_name = "Id#{MongoidClassForCollection.unique_id}"
5
+ class_name = collection.to_s.classify
6
+ eval <<-CLASSDEF
7
+ module #{module_name}
8
+ class #{class_name}
9
+ include Mongoid::Document
10
+ store_in '#{collection}'
11
+ end
12
+ end
13
+ CLASSDEF
14
+
15
+ klass = eval("#{module_name}::#{class_name}")
16
+ klass.class_eval &blk if block_given?
17
+ klass
18
+ end
19
+
20
+ def self.unique_id
21
+ @unique_id ||= 0
22
+ @unique_id += 1
23
+ end
24
+ end
25
+
26
+ # Add this to your migration class
27
+ # extend MongoidClassForCollection
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "mongoid_class_for_collection/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "mongoid_class_for_collection"
7
+ s.version = MongoidClassForCollection::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Shawn Anderson", "Sivabudh Umpudh"]
10
+ s.email = ["shawn42@gmail.com", "siva@atomicobject.com"]
11
+ s.homepage = "http://rubygems.org/gems/mongoid_class_for_collection"
12
+ s.summary = %q{Makes migrations more flexible by creating dynamic classes for you to use}
13
+ s.description = %q{Makes migrations more flexible by creating dynamic classes for you to use with mongoid_rails_migrations gem.}
14
+
15
+ s.rubyforge_project = "mongoid_class_for_collection"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_class_for_collection
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Shawn Anderson
9
+ - Sivabudh Umpudh
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-05-27 00:00:00 -04:00
15
+ default_executable:
16
+ dependencies: []
17
+
18
+ description: Makes migrations more flexible by creating dynamic classes for you to use with mongoid_rails_migrations gem.
19
+ email:
20
+ - shawn42@gmail.com
21
+ - siva@atomicobject.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - .gitignore
30
+ - Gemfile
31
+ - README.md
32
+ - Rakefile
33
+ - lib/mongoid_class_for_collection.rb
34
+ - lib/mongoid_class_for_collection/version.rb
35
+ - mongoid_class_for_collection.gemspec
36
+ has_rdoc: true
37
+ homepage: http://rubygems.org/gems/mongoid_class_for_collection
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ requirements: []
58
+
59
+ rubyforge_project: mongoid_class_for_collection
60
+ rubygems_version: 1.5.1
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Makes migrations more flexible by creating dynamic classes for you to use
64
+ test_files: []
65
+