power_enum 3.4.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +12 -28
- data/VERSION +1 -0
- data/lib/power_enum/enumerated.rb +445 -440
- data/lib/power_enum/has_enumerated.rb +175 -172
- data/lib/power_enum.rb +26 -16
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afdfec8c704c968a3871c9444428cb385fcc3075bb56875a4018e4cf0f9ba5c0
|
4
|
+
data.tar.gz: 640c7bde6091cbe26b8263a000cb922c0df3c2c6e113c17d0c7846305873ee67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2198b9d106a9428ae0ae1f70f1d15cc4c1874909d5870b5da43592878000791f2d0fe51e012fd6766a9bc00e4518c083430f68d1f894ece0e9a890c37a913fb4
|
7
|
+
data.tar.gz: 43e95cce4ffc0f4fe4e0fb4fe150d944fddea41bf89b530d2bcee20ff82b1bdea1783a3fc3db2580daa95086e7c51b53df650aae9ad90f83293792635b9dfd4c
|
data/README.markdown
CHANGED
@@ -29,16 +29,17 @@ At it's most basic level, it allows you to say things along the lines of:
|
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
# Create a provisional booking
|
32
|
-
booking = Booking.new( :
|
32
|
+
booking = Booking.new( status: BookingStatus[:provisional] )
|
33
33
|
# This also works
|
34
|
-
booking = Booking.new( :
|
34
|
+
booking = Booking.new( status: :provisional )
|
35
35
|
# Set the booking status to 'confirmed'
|
36
36
|
booking.status = :confirmed
|
37
|
-
booking = Booking.create( :
|
37
|
+
booking = Booking.create( status: :rejected )
|
38
38
|
# And now...
|
39
39
|
booking.status == BookingStatus[:rejected] # evaluates to true
|
40
40
|
booking.status === :rejected # also evaluates to true
|
41
41
|
booking.status === [:rejected, :confirmed, :provisional] # and so does this
|
42
|
+
booking.status === [%i[rejected confirmed provisional]] # and this
|
42
43
|
|
43
44
|
Booking.where( :status_id => BookingStatus[:provisional] )
|
44
45
|
|
@@ -63,26 +64,7 @@ See "How to use it" below for more information.
|
|
63
64
|
|
64
65
|
## Installation
|
65
66
|
|
66
|
-
###
|
67
|
-
|
68
|
-
This gem is signed. The public key is available
|
69
|
-
here: https://github.com/albertosaurus/power_enum (look for gem-public\_cert.pem). Hence, if
|
70
|
-
you can get an error like the following if you're installing in `HighSecurity` mode.
|
71
|
-
|
72
|
-
```
|
73
|
-
ERROR: While executing gem ... (RuntimeError)
|
74
|
-
Couldn't verify data signature: Untrusted Signing Chain Root: cert = 'cert name', error = 'path "/your_gem_home/.gem/trust/cert-blah.pem" does not exist'
|
75
|
-
```
|
76
|
-
|
77
|
-
If this happens, you need to add the PowerEnum public cert to your gem cert
|
78
|
-
store. Download the certificate (gem-public\_cert.pem) and run the following.
|
79
|
-
|
80
|
-
gem cert -a gem-public_cert.pem
|
81
|
-
|
82
|
-
More information is available at http://guides.rubygems.org/security/
|
83
|
-
which I strongly urge you to read.
|
84
|
-
|
85
|
-
#### Using Bundler
|
67
|
+
### Using Bundler
|
86
68
|
|
87
69
|
Add the gem to your Gemfile
|
88
70
|
|
@@ -92,7 +74,7 @@ then run
|
|
92
74
|
|
93
75
|
bundle install
|
94
76
|
|
95
|
-
|
77
|
+
### Manual Installation
|
96
78
|
|
97
79
|
gem install power_enum
|
98
80
|
|
@@ -298,10 +280,12 @@ drop_table :booking_statuses
|
|
298
280
|
class BookingStatus < ActiveRecord::Base
|
299
281
|
acts_as_enumerated :conditions => 'optional_sql_conditions',
|
300
282
|
:order => 'optional_sql_order_by',
|
301
|
-
:on_lookup_failure => :optional_class_method, #This also works: lambda{ |arg| some_custom_action }
|
302
|
-
:name_column => 'optional_name_column' #If required, may override the default name column
|
303
|
-
:alias_name => false
|
304
|
-
#
|
283
|
+
:on_lookup_failure => :optional_class_method, # This also works: lambda{ |arg| some_custom_action }
|
284
|
+
:name_column => 'optional_name_column' # If required, may override the default name column
|
285
|
+
:alias_name => false, # If set to false and have name_column set, will not
|
286
|
+
# alias :name to the name column attribute.
|
287
|
+
:freeze_members => true # Optional, default is true in prod.
|
288
|
+
# This also works: lambda { true }
|
305
289
|
end
|
306
290
|
```
|
307
291
|
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.7.0
|