laserlemon-hot_serial 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/hot_serial.gemspec +1 -1
  3. data/lib/serializer.rb +32 -0
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/hot_serial.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hot_serial}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["laserlemon"]
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laserlemon-hot_serial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - laserlemon