mongoid-enum 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRmYzVkMTg5OTZiZjlmNDVkMjk2NDk1ODIxNDI0Zjc2NWZkNGNhMg==
4
+ NTJkYTBhNGI1MDQ1OTAyMDdmZDU1NGMxODFkNjI5YTBlNTczNTQwNA==
5
5
  data.tar.gz: !binary |-
6
- MjU1MDU0MDJkZjE3YjIxM2M2MjY1NWE2NDNiN2UzNjMyOWY5Nzg4Nw==
6
+ MzgxMTU4ZjJhYzA0ZTg5ZWZjY2QzOGM5YWM4N2NmNDZiODBjYThkZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDU1Yjc2NmZjNTkxZTc1NTVkNjk2NjA0YTRkYjVjNzRjNDgyNzIzYzIzZmVl
10
- NDNjZDQwMWJlZTNhZTI3OWYzYTg5M2NhMWRmZjNmYzFlYzM5MjY1MDc5NWY5
11
- M2EyYmJjZjYwMThlZWI3Y2M1ZGUzZTA4YTUwNzc5ZWRlNWUxYzA=
9
+ ZTExODM0ZDEwN2I1MGZhNzZmMjNmOGM3MjFkOGNlYWI2ZWFlNjY2NGI5YTEx
10
+ ZDdiMTU2OTJjMmFmMTQzZThhODhkNmJkMDUzYTJlODI1YWExOWU0ZmU1OGYy
11
+ ZTYwNmFlNDZiZGEwZGM0MmNkODNlM2IzYWViNTJlNGJjNjZmODY=
12
12
  data.tar.gz: !binary |-
13
- OGRmOWM1OGY2NDljNmUzOWJiNTEwMjA4NDBmODc0YjMyZDgzNmRkNWMyZDlj
14
- MjVmNzE4MTY0Yzk0MDNhMjhjMWUwZGNkOGY3MDJhOGE3ODliZTY4OGVkZjA3
15
- OTMxNWYwYTllOGRjZjA4YmRmNmJiNjk1ZGE5M2ZlYzVjNmIwMzE=
13
+ MWVkNDk1ODg1YWVjZWM5Y2U5NzQ3NmFlNjY4N2Y2N2Y2OTQyMzQ5Y2U5N2Zh
14
+ MTExODgyNzQxYThiMGQxZjQwMzYzY2Q1MzFjZjIxZWE2NmMzZDE5ZmI2MDdl
15
+ NDVjYmQwODBlYmJkZWViY2JjY2MyZTdhMjljMWYwYTk2NDYyODU=
data/README.md CHANGED
@@ -5,7 +5,7 @@ Status](https://travis-ci.org/thetron/mongoid-enum.png)](https://travis-ci.org/t
5
5
 
6
6
  Heavily inspired by [DHH's
7
7
  ActiveRecord::Enum](https://github.com/rails/rails/commit/db41eb8a6ea88b854bf5cd11070ea4245e1639c5), this little library is
8
- just there to help you cut down the cruft in your models and make the
8
+ there to help you cut down the cruft in your models and make the
9
9
  world a happier place at the same time.
10
10
 
11
11
  A single line will get you fields, accessors, validations and scopes,
@@ -73,7 +73,7 @@ payment.status
73
73
  ````
74
74
 
75
75
  And you also get bang(!) and query(?) methods for each of the values in
76
- your enum (see [this example](#Usage).
76
+ your enum (see [this example](#usage).
77
77
 
78
78
 
79
79
  ## Constants
@@ -91,7 +91,7 @@ Payment::STATUS
91
91
  ## Validations
92
92
 
93
93
  Enum values are automatically validated against the list. You can
94
- disable this behaviour (see (below)[#Options]).
94
+ disable this behaviour (see [below](#options)).
95
95
 
96
96
 
97
97
  ## Scopes
@@ -141,4 +141,12 @@ your field are always from your list of options. If you need more
141
141
  complex validations, or you just want to throw caution to the wind, you
142
142
  can turn them off:
143
143
 
144
- enum :status => [:up, :down], :validation => false
144
+ enum :status => [:up, :down], :validate => false
145
+
146
+
147
+ # Issues and Feature Requests
148
+
149
+ If you have any problems, or you have a suggestion, please [submit an
150
+ issue](https://github.com/thetron/mongoid-enum/issues) (and a failing
151
+ test, if you can). Pull requests and feature requests are alwasy welcome
152
+ and greatly appreciated.
@@ -11,6 +11,7 @@ module Mongoid
11
11
  multiple = options[:multiple] || false
12
12
  default = options[:default].nil? && values.first || options[:default]
13
13
  required = options[:required].nil? || options[:required]
14
+ validate = options[:validate].nil? || options[:validate]
14
15
 
15
16
  const_set const_name, values
16
17
 
@@ -18,9 +19,9 @@ module Mongoid
18
19
  field field_name, :type => type, :default => default
19
20
  alias_attribute name, field_name
20
21
 
21
- if multiple
22
+ if multiple && validate
22
23
  validates field_name, :'mongoid/enum/validators/multiple' => { :in => values, :allow_nil => !required }
23
- else
24
+ elsif validate
24
25
  validates field_name, :inclusion => {:in => values}, :allow_nil => !required
25
26
  end
26
27
 
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Enum
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Mongoid::Enum::VERSION
9
9
  spec.authors = ["Nicholas Bruning"]
10
10
  spec.email = ["nicholas@bruning.com.au"]
11
- spec.description = %q{Heavily inspired by DDH's ActiveRecord::Enum, this little library is just there to help you cut down the cruft in your models and make the world a happier place at the same time.}
11
+ spec.description = %q{Heavily inspired by DDH's ActiveRecord::Enum, this little library is there to help you cut down the cruft in your models and make the world a happier place at the same time.}
12
12
  spec.summary = %q{Sweet enum sugar for your Mongoid documents}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/thetron/mongoid-enum"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Bruning
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.5.1
111
111
  description: Heavily inspired by DDH's ActiveRecord::Enum, this little library is
112
- just there to help you cut down the cruft in your models and make the world a happier
112
+ there to help you cut down the cruft in your models and make the world a happier
113
113
  place at the same time.
114
114
  email:
115
115
  - nicholas@bruning.com.au
@@ -133,7 +133,7 @@ files:
133
133
  - spec/mongoid/enum_spec.rb
134
134
  - spec/spec_helper.rb
135
135
  - spec/support/mongoid.yml
136
- homepage: ''
136
+ homepage: https://github.com/thetron/mongoid-enum
137
137
  licenses:
138
138
  - MIT
139
139
  metadata: {}