serialist 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/serialist/serialist_module.rb +16 -3
- data/serialist.gemspec +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -96,6 +96,8 @@ Allows you to serialize anything. ex :
|
|
96
96
|
>> a
|
97
97
|
=> #<Article id: XX, title: nil, created_at: "..", updated_at: "..", slug: {:foo=>"hello"}>
|
98
98
|
|
99
|
+
It's not a pure method_missing anyway, I cheated a bit, I use on-demand define_method before mass-assignements.
|
100
|
+
|
99
101
|
== Word of caution:
|
100
102
|
|
101
103
|
Other than the specific notice about not using method1 with Serialist loaded before other ActiveRecord "automagicians" plugins, watch out for conflict with existing attributes and methods!
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# ActsAsSerializable
|
2
1
|
module Serialist
|
3
2
|
|
4
3
|
def self.included(base)
|
@@ -10,8 +9,6 @@ module Serialist
|
|
10
9
|
attr_accessor :serialist_field
|
11
10
|
|
12
11
|
def serialist(serialist_field, serialist_options = [])
|
13
|
-
|
14
|
-
|
15
12
|
@serialist_field ||= serialist_field
|
16
13
|
@serialist_options ||= []
|
17
14
|
@serialist_options = (@serialist_options + serialist_options).uniq
|
@@ -49,6 +46,22 @@ module Serialist
|
|
49
46
|
end
|
50
47
|
|
51
48
|
module InstanceMethods
|
49
|
+
|
50
|
+
def attributes=(new_attributes, guard_protected_attributes = true)
|
51
|
+
return if new_attributes.nil?
|
52
|
+
attributes = new_attributes.dup
|
53
|
+
attributes.stringify_keys!
|
54
|
+
attributes.each do |k, v|
|
55
|
+
unless k.include?("(") || respond_to?(:"#{k}=")
|
56
|
+
self.class.send(:define_method, :"#{k}=") do |param|
|
57
|
+
update_attribute(self.class.serialist_field, Hash.new) unless self.send(self.class.serialist_field)
|
58
|
+
self.send(self.class.serialist_field)[k] = param
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
52
65
|
def method_missing(method, *args, &block)
|
53
66
|
begin
|
54
67
|
super
|
data/serialist.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{serialist}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Benoit B\303\251n\303\251zech"]
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.homepage = %q{http://github.com/bbenezech/serialist}
|
40
40
|
s.rdoc_options = ["--charset=UTF-8"]
|
41
41
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.3.
|
42
|
+
s.rubygems_version = %q{1.3.5}
|
43
43
|
s.summary = %q{Serialize any data, set and fetch it like any column attributes}
|
44
44
|
s.test_files = [
|
45
45
|
"test/acts_as_serializable_test.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serialist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Benoit B\xC3\xA9n\xC3\xA9zech"
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements: []
|
66
66
|
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.3.
|
68
|
+
rubygems_version: 1.3.5
|
69
69
|
signing_key:
|
70
70
|
specification_version: 3
|
71
71
|
summary: Serialize any data, set and fetch it like any column attributes
|