sql_enum 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/enum/enum_type.rb +1 -1
- data/lib/active_record/enum_override.rb +5 -1
- data/lib/sql_enum/version.rb +1 -1
- data/lib/sql_enum.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e66d89471635b35ba4a82a44cbdba443120926c
|
4
|
+
data.tar.gz: bc24ffca63ef8480683d5bed1027a5104d23d94b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e8faa146d9d0b72b09e2822834659ff1c4c1ddbb80175b226df6df923603f1fb02eaa678af4b044887d12a31b03cfaaf4d275f9f7b2d275c1212c50efd27521
|
7
|
+
data.tar.gz: 46a7a0b34a9aaeddf20016745c4dd2d73e02005bc1a4ea1bb6e7ce05094ead55c0509bb7f945548b121a608e1ac73fc2f5f7c08fc401ccf20372e45eb9c07ae6
|
@@ -5,6 +5,10 @@ module ActiveRecord
|
|
5
5
|
def sql_enum(name, options={})
|
6
6
|
enum_prefix = options.delete(:_prefix)
|
7
7
|
enum_suffix = options.delete(:_suffix)
|
8
|
+
|
9
|
+
enum_prefix ||= name if SqlEnum.configuration.default_prefix
|
10
|
+
enum_suffix ||= name if SqlEnum.configuration.default_suffix
|
11
|
+
|
8
12
|
klass = self
|
9
13
|
enum_values = Array.new
|
10
14
|
name = name.to_sym
|
@@ -37,7 +41,7 @@ module ActiveRecord
|
|
37
41
|
|
38
42
|
# def active?() status == 0 end
|
39
43
|
klass.send(:detect_enum_conflict!, name, "#{value_method_name}?")
|
40
|
-
define_method("#{value_method_name}?") { self[attr] == value.to_s }
|
44
|
+
define_method("#{value_method_name}?") { binding.pry; self[attr] == value.to_s }
|
41
45
|
|
42
46
|
# def active!() update! status: :active end
|
43
47
|
klass.send(:detect_enum_conflict!, name, "#{value_method_name}!")
|
data/lib/sql_enum/version.rb
CHANGED
data/lib/sql_enum.rb
CHANGED
@@ -9,4 +9,21 @@ require_relative 'active_record/connection_adapters/mysql/column_methods'
|
|
9
9
|
require_relative "sql_enum/version"
|
10
10
|
|
11
11
|
module SqlEnum
|
12
|
+
class << self
|
13
|
+
attr_accessor :configuration
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
self.configuration ||= Configuration.new
|
18
|
+
yield(configuration)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Configuration
|
22
|
+
attr_accessor :default_prefix, :default_suffix
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
@default_prefix = false
|
26
|
+
@default_suffix = false
|
27
|
+
end
|
28
|
+
end
|
12
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Fowler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|