Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cerebroso/saasable
base: c0bfb9a0e6
...
head fork: cerebroso/saasable
compare: 51b055ecfb
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
1  Gemfile
@@ -8,4 +8,5 @@ group :development do
gem "rspec"
gem "bundler"
gem "jeweler"
+ gem 'rdoc'
end
View
4 Gemfile.lock
@@ -16,6 +16,7 @@ GEM
bundler (~> 1.0)
git (>= 1.2.5)
rake
+ json (1.6.5)
mongo (1.4.0)
bson (= 1.4.0)
mongoid (2.3.3)
@@ -24,6 +25,8 @@ GEM
tzinfo (~> 0.3.22)
multi_json (1.0.3)
rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
@@ -41,4 +44,5 @@ DEPENDENCIES
bundler
jeweler
mongoid
+ rdoc
rspec
View
2  VERSION
@@ -1 +1 @@
-0.2.0
View
20 lib/saasable/mongoid/scoped_document.rb
@@ -1,26 +1,34 @@
module Saasable::Mongoid::ScopedDocument
@scoped_documents = []
-
+
def self.included klass
@scoped_documents << klass unless @scoped_documents.include? klass
-
+
klass.extend ClassMethods
klass.class_eval do
field :saas_id, :type => BSON::ObjectId
end
end
-
+
def self.scoped_documents
@scoped_documents
end
-
+
+ def saas= a_saas
+ self.saas_id = a_saas._id
+ end
+
+ def saas
+ @saas ||= Saasable::Mongoid::SaasDocument.saas_document.find(self.saas_id)
+ end
+
module ClassMethods
def validates_uniqueness_of(*args)
attributes = _merge_attributes(args)
attributes[:scope] ||= []
attributes[:scope] << :saas_id unless attributes[:scope].include?(:saas_id)
-
+
validates_with(Mongoid::Validations::UniquenessValidator, attributes)
end
end
-end
+end

No commit comments for this range

Something went wrong with that request. Please try again.