characterizable 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/characterizable.gemspec +2 -2
- data/lib/characterizable.rb +13 -10
- data/test/helper.rb +1 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
data/characterizable.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{characterizable}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.17"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andy Rossmeissl", "Seamus Abshere"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-30}
|
13
13
|
s.description = %q{Characterize the relationship between "attributes" (getters/setters) of instances of a class}
|
14
14
|
s.email = %q{seamus@abshere.net}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/characterizable.rb
CHANGED
@@ -28,7 +28,7 @@ module Characterizable
|
|
28
28
|
|
29
29
|
class BetterHash < ::Hash
|
30
30
|
# In Ruby 1.9, running select/reject/etc. gives you back a hash
|
31
|
-
if RUBY_VERSION < '1.9'
|
31
|
+
# if RUBY_VERSION < '1.9'
|
32
32
|
def to_hash
|
33
33
|
Hash.new.replace self
|
34
34
|
end
|
@@ -61,7 +61,7 @@ module Characterizable
|
|
61
61
|
memo
|
62
62
|
end
|
63
63
|
end
|
64
|
-
end
|
64
|
+
# end
|
65
65
|
end
|
66
66
|
|
67
67
|
class Snapshot < BetterHash
|
@@ -141,17 +141,20 @@ module Characterizable
|
|
141
141
|
characteristics[name] = Characteristic.new(self, name, options, &block)
|
142
142
|
begin
|
143
143
|
# quacks like an activemodel
|
144
|
-
klass.define_attribute_methods
|
144
|
+
klass.define_attribute_methods unless klass.respond_to?(:attribute_methods_generated?) and klass.attribute_methods_generated?
|
145
145
|
rescue
|
146
146
|
# for example, if a table doesn't exist... just ignore it
|
147
147
|
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
148
|
+
begin
|
149
|
+
klass.module_eval(%{
|
150
|
+
def #{name}_with_expire_snapshot=(new_#{name})
|
151
|
+
expire_snapshot!
|
152
|
+
self.#{name}_without_expire_snapshot = new_#{name}
|
153
|
+
end
|
154
|
+
alias_method_chain :#{name}=, :expire_snapshot
|
155
|
+
}, __FILE__, __LINE__) #if klass.instance_methods.include?("#{name}=")
|
156
|
+
rescue
|
157
|
+
end
|
155
158
|
end
|
156
159
|
end
|
157
160
|
class Characteristic
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: characterizable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 17
|
10
|
+
version: 0.0.17
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-09-30 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|