rails_attr_enum 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e50e904586e33747717a8578df7a9ba7b6ca4d9b
4
- data.tar.gz: c5b49a433cf04cd9ba9008e67236d9c6c71bb9ea
3
+ metadata.gz: 594e470d58bf61cf2a5a268d001ffd9350ed350d
4
+ data.tar.gz: 2c06a6695f1830ddd243128fd7ccd40d5e963ced
5
5
  SHA512:
6
- metadata.gz: 3ab5f0e629717b89d5e5b25bc62abd9d3049a37c7581c8db12657368e63f24042a04045b996610e6927ddaf6c092e84f69ea5d8bafd4c2863706abb76ce64e5c
7
- data.tar.gz: 4bda9c9c484c99d659683be72a0e70e8d2797a35d0b5d0c6a4b3a38ee21619fddba73fd904aa2ee924aa1510d74668aa6235e48b4585e93746541b3919dff2fd
6
+ metadata.gz: d14af5e3c4f4b2b79dc8b7c966e3df7677d3a5b59b026f84005ee1b8a89ea0b24e573fcc90dd6e1f790facc99b0625f6b21eb2633a9798f8f504e5e0764f302d
7
+ data.tar.gz: 8a94f8c39d9c41c6675c9de3f6cadee2e9814876c51e5df2056c840203b91e4341ba19d0638cb3920edad9e8274da4faee0252173be174965a58c9d634911e10
@@ -11,7 +11,7 @@ module RailsAttrEnum
11
11
  if block_given?
12
12
  add_attr_enum_through_block(attr_name, &block)
13
13
  else
14
- if keys.first.is_a?(Hash)
14
+ if keys.first.is_a?(Hash) && keys.first.size > 1
15
15
  add_attr_enum_through_block(attr_name) do
16
16
  keys.first.each { |k, v| add k => v }
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAttrEnum
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,5 +1,25 @@
1
1
  class User < ActiveRecord::Base
2
2
  extend RailsAttrEnum
3
3
 
4
- attr_enum :role, :admin, :author, :editor
4
+ # attr_enum :role, :admin, :author, :editor, :user
5
+ # attr_enum :role, :admin, { author: 2 }, :editor, { user: 10 }
6
+
7
+ attr_enum :role, { admin: { value: 10, label: 'ADMIN' } },
8
+ { author: 'Author Role' },
9
+ :editor,
10
+ { user: { label: 'ID10T', value: 45 } }
11
+
12
+ # attr_enum :role, {
13
+ # admin: 'ADMIN',
14
+ # author: 'AUTHOR',
15
+ # editor: 'EDITOR',
16
+ # user: 'ID10T'
17
+ # }
18
+
19
+ # attr_enum :role do
20
+ # add admin: 1
21
+ # add :author
22
+ # add editor: 42
23
+ # add user: 7
24
+ # end
5
25
  end
Binary file
@@ -22,3 +22,13 @@ Migrating to CreateUsers (20131023212242)
22
22
  User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
23
23
  User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
24
24
  User Load (0.2ms) SELECT "users".* FROM "users"
25
+ User Load (0.7ms) SELECT "users".* FROM "users"
26
+  (0.1ms) begin transaction
27
+ SQL (17.1ms) DELETE FROM "users" WHERE "users"."id" = ? [["id", 1]]
28
+  (1.4ms) commit transaction
29
+  (0.1ms) begin transaction
30
+ SQL (0.4ms) DELETE FROM "users" WHERE "users"."id" = ? [["id", 2]]
31
+  (1.1ms) commit transaction
32
+  (0.1ms) begin transaction
33
+ SQL (0.3ms) DELETE FROM "users" WHERE "users"."id" = ? [["id", 3]]
34
+  (1.2ms) commit transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_attr_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Fairbank