laserlemon-hot_serial 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/hot_serial.gemspec +1 -1
- data/lib/serializer.rb +32 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/hot_serial.gemspec
CHANGED
data/lib/serializer.rb
CHANGED
@@ -2,8 +2,10 @@ module LaserLemon
|
|
2
2
|
module HotSerial
|
3
3
|
module Serializer
|
4
4
|
def self.included(base)
|
5
|
+
puts 'Serializer'
|
5
6
|
base.alias_method_chain :initialize, :breakfast
|
6
7
|
base.alias_method_chain :add_includes, :breakfast
|
8
|
+
base.alias_method_chain :serializable_names, :breakfast
|
7
9
|
end
|
8
10
|
|
9
11
|
def initialize_with_breakfast(record, options = nil)
|
@@ -45,8 +47,38 @@ module LaserLemon
|
|
45
47
|
options[:include] = include_associations
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
def serializable_names_with_breakfast
|
52
|
+
serializable_names_without_breakfast.sort_by(&:to_s)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module XmlSerializer
|
57
|
+
def self.included(base)
|
58
|
+
puts 'XMLSerializer'
|
59
|
+
base.alias_method_chain :add_attributes, :breakfast
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_attributes_with_breakfast
|
63
|
+
(serializable_attributes + serializable_method_attributes).sort.each do |attribute|
|
64
|
+
add_tag(attribute)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module Attribute
|
69
|
+
def self.included(base)
|
70
|
+
puts 'Attribute'
|
71
|
+
base.send(:include, Comparable)
|
72
|
+
end
|
73
|
+
|
74
|
+
def <=>(other)
|
75
|
+
name.to_s <=> other.name.to_s
|
76
|
+
end
|
77
|
+
end
|
48
78
|
end
|
49
79
|
end
|
50
80
|
end
|
51
81
|
|
52
82
|
ActiveRecord::Serialization::Serializer.send(:include, LaserLemon::HotSerial::Serializer)
|
83
|
+
ActiveRecord::XmlSerializer.send(:include, LaserLemon::HotSerial::XmlSerializer)
|
84
|
+
ActiveRecord::XmlSerializer::Attribute.send(:include, LaserLemon::HotSerial::XmlSerializer::Attribute)
|