mongo_mapper-strict_keys 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ### In your Gemfile:
6
6
 
7
- gem 'mongo_mapper-strict_keys', '~>0.0.4'
7
+ gem 'mongo_mapper-strict_keys', '~>0.0.5'
8
8
 
9
9
  To force strict keys for all models, from the outset:
10
10
 
11
- gem 'mongo_mapper-strict_keys', '~>0.0.4', :require => 'mongo_mapper/strict_keys/force_plugin'
11
+ gem 'mongo_mapper-strict_keys', '~>0.0.5', :require => 'mongo_mapper/strict_keys/force_plugin'
12
12
 
13
13
  ### In your Source Code / Model:
14
14
 
@@ -16,5 +16,8 @@ To force strict keys for all models, from the outset:
16
16
 
17
17
  class StrictModel
18
18
  include MongoMapper::Document
19
- include MongoMapper::Plugins::StrictKeys
19
+
20
+ strict_keys!
20
21
  end
22
+
23
+ If you already required the force\_plugin, then you don't need to specify 'strict_keys!'
@@ -11,10 +11,15 @@ module MongoMapper
11
11
  module ClassMethods; end
12
12
 
13
13
  module InstanceMethods
14
+ # @param [Symbol, String] name The name of the key to be ensured
15
+ # @return [true] This method either returns true or raises an exception
16
+ # @raise [ArgumentError] If 'name' has not been specified as a key
17
+ # @see MongoMapper::Plugins::Keys#key
14
18
  def ensure_key_exists(name)
15
19
  unless respond_to?("#{name}=")
16
20
  raise ArgumentError.new("Attribute '#{name}' has not been explicitly defined as a key.")
17
21
  end
22
+ true
18
23
  end
19
24
  end
20
25
 
@@ -1,7 +1,7 @@
1
1
  module MongoMapper
2
2
  module Plugins
3
3
  module StrictKeys
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mongo_mapper-strict_keys
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Scott Gonyea