torque-postgresql 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/torque/postgresql/attributes/enum.rb +7 -3
- data/lib/torque/postgresql/base.rb +10 -5
- data/lib/torque/postgresql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc336d84a0f18fb43d39e8bcb62675ec27e4858
|
4
|
+
data.tar.gz: 9d379870667fbee69ab9462ecae7264794721c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb36ee1d4b3a9bb0577dd78ed856fc2a6de4e5525d5c32d74c071b88ad3cf124b348dbbc776122921f4d9d084b2bd558faf98382ff2b5854b0de93f6a8f1c82a
|
7
|
+
data.tar.gz: 5c59b4cace85d923cfcbf01bc4f265f7a192b9f1dd9810d49348706604c554ce4b54bfdb5697d6bbaefebfe38f8adde7684cce255d4c3777516557436b86086a
|
@@ -9,11 +9,11 @@ module Torque
|
|
9
9
|
LAZY_VALUE = 0.chr
|
10
10
|
|
11
11
|
class << self
|
12
|
-
delegate :each, to: :values
|
12
|
+
delegate :each, :sample, to: :values
|
13
13
|
|
14
14
|
# Find or create the class that will handle the value
|
15
15
|
def lookup(name)
|
16
|
-
const = name.camelize
|
16
|
+
const = name.to_s.camelize
|
17
17
|
namespace = Torque::PostgreSQL.config.enum.namespace
|
18
18
|
|
19
19
|
return namespace.const_get(const) if namespace.const_defined?(const)
|
@@ -71,7 +71,7 @@ module Torque
|
|
71
71
|
# Allow fast creation of values
|
72
72
|
def method_missing(method_name, *arguments)
|
73
73
|
return super if self == Enum
|
74
|
-
|
74
|
+
valid?(method_name) ? new(method_name.to_s) : super
|
75
75
|
end
|
76
76
|
|
77
77
|
# Get a connection based on its name
|
@@ -226,6 +226,10 @@ module Torque
|
|
226
226
|
# Mark the enum as defined
|
227
227
|
defined_enums[attribute] = subtype.klass
|
228
228
|
end
|
229
|
+
|
230
|
+
Torque::PostgreSQL.config.enum.namespace.define_singleton_method(:const_missing) do |name|
|
231
|
+
Enum.lookup(name)
|
232
|
+
end
|
229
233
|
end
|
230
234
|
end
|
231
235
|
end
|
@@ -3,14 +3,19 @@ module Torque
|
|
3
3
|
module Base
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
included do
|
7
|
-
class_attribute :auxiliary_statements_list, instance_accessor: true
|
8
|
-
self.auxiliary_statements_list = {}
|
9
|
-
end
|
10
|
-
|
11
6
|
module ClassMethods
|
12
7
|
delegate :distinct_on, :with, to: :all
|
13
8
|
|
9
|
+
private
|
10
|
+
|
11
|
+
# Wenever it's inherited, add a new list of auxiliary statements
|
12
|
+
def inherited(subclass)
|
13
|
+
subclass.class_eval do
|
14
|
+
class_attribute :auxiliary_statements_list, instance_accessor: true
|
15
|
+
self.auxiliary_statements_list = Hash.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
14
19
|
protected
|
15
20
|
|
16
21
|
# Creates a new auxiliary statement (CTE) under the base class
|