jqr-typed_serialize 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Manifest +1 -0
- data/lib/typed_serialize.rb +7 -9
- data/typed_serialize.gemspec +3 -3
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
data/lib/typed_serialize.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
class ActiveRecord::Base
|
2
|
-
def self.typed_serialize(attr_name, class_name
|
2
|
+
def self.typed_serialize(attr_name, class_name)
|
3
3
|
serialize(attr_name, class_name)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
self.send("#{attr_name}=", expected_class.new)
|
12
|
-
end
|
5
|
+
define_method(attr_name) do
|
6
|
+
expected_class = self.class.serialized_attributes[attr_name.to_s]
|
7
|
+
if (value = super).is_a?(expected_class)
|
8
|
+
value
|
9
|
+
else
|
10
|
+
self.send("#{attr_name}=", expected_class.new)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
data/typed_serialize.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{typed_serialize}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Elijah Miller"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-26}
|
10
10
|
s.description = %q{Typed serialize makes sure your serialized attribute is always the specified type.}
|
11
11
|
s.email = %q{elijah.miller@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/typed_serialize.rb", "LICENSE", "README.rdoc"]
|
13
|
-
s.files = ["CHANGELOG", "init.rb", "install.rb", "lib/typed_serialize.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "
|
13
|
+
s.files = ["CHANGELOG", "init.rb", "install.rb", "lib/typed_serialize.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "typed_serialize.gemspec", "uninstall.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Typed_serialize", "--main", "README.rdoc"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jqr-typed_serialize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elijah Miller
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-26 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -41,8 +41,8 @@ files:
|
|
41
41
|
- Manifest
|
42
42
|
- Rakefile
|
43
43
|
- README.rdoc
|
44
|
-
- uninstall.rb
|
45
44
|
- typed_serialize.gemspec
|
45
|
+
- uninstall.rb
|
46
46
|
has_rdoc: true
|
47
47
|
homepage: ""
|
48
48
|
post_install_message:
|