mcfly 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mcfly/has_mcfly.rb +10 -5
- data/lib/mcfly/version.rb +1 -1
- metadata +2 -2
data/lib/mcfly/has_mcfly.rb
CHANGED
@@ -2,7 +2,8 @@ require 'delorean_lang'
|
|
2
2
|
|
3
3
|
module Mcfly
|
4
4
|
module Model
|
5
|
-
|
5
|
+
INFINITIES = Set[Float::INFINITY, 'infinity', 'Infinity']
|
6
|
+
|
6
7
|
class AssociationValidator < ActiveModel::Validator
|
7
8
|
VALSET = Set[nil, Float::INFINITY, 'infinity']
|
8
9
|
|
@@ -41,6 +42,10 @@ module Mcfly
|
|
41
42
|
def mcfly_lookup(name, options = {}, &block)
|
42
43
|
delorean_fn(name, options) do |ts, *args|
|
43
44
|
raise "time cannot be nil" if ts.nil?
|
45
|
+
|
46
|
+
# normalize infinity
|
47
|
+
ts = 'infinity' if Mcfly::Model::INFINITIES.member? ts
|
48
|
+
|
44
49
|
self.where("#{table_name}.obsoleted_dt >= ? AND " +
|
45
50
|
"#{table_name}.created_dt < ?", ts, ts).scoping do
|
46
51
|
block.call(ts, *args)
|
@@ -61,7 +66,7 @@ module Mcfly
|
|
61
66
|
|
62
67
|
# add :obsoleted_dt to the uniqueness scope
|
63
68
|
attr_names.last[:scope] << :obsoleted_dt
|
64
|
-
|
69
|
+
|
65
70
|
# Set uniqueness error message if not set. FIXME: need to
|
66
71
|
# figure out how to change the base message. It still
|
67
72
|
# prepends the pluralized main attr.
|
@@ -82,7 +87,7 @@ module Mcfly
|
|
82
87
|
a.klass.class_variable_set(:@@associations, []) unless
|
83
88
|
a.klass.class_variable_defined?(:@@associations)
|
84
89
|
|
85
|
-
a.klass.class_variable_get(:@@associations) <<
|
90
|
+
a.klass.class_variable_get(:@@associations) <<
|
86
91
|
[a.active_record, a.foreign_key]
|
87
92
|
end
|
88
93
|
end
|
@@ -102,7 +107,7 @@ module Mcfly
|
|
102
107
|
# checks against registered associations
|
103
108
|
if self.class.class_variable_defined?(:@@associations)
|
104
109
|
self.class.class_variable_get(:@@associations).each do |klass, fk|
|
105
|
-
self.errors.add :base,
|
110
|
+
self.errors.add :base,
|
106
111
|
"#{self.class.name.demodulize} cannot be deleted " +
|
107
112
|
"because #{klass.name.demodulize} records exist" if
|
108
113
|
klass.where("obsoleted_dt = 'infinity' and
|
@@ -114,6 +119,6 @@ module Mcfly
|
|
114
119
|
end
|
115
120
|
|
116
121
|
end
|
117
|
-
|
122
|
+
|
118
123
|
end
|
119
124
|
end
|
data/lib/mcfly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcfly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|