Browse files

remove serialize_options

  • Loading branch information...
1 parent 826ed6d commit f41eaaec8dd0c3225e0ab0fe8a76df4fee27cea7 @maccman maccman committed Aug 26, 2011
Showing with 0 additions and 68 deletions.
  1. +0 −64 lib/active_model/serialize_options.rb
  2. +0 −4 lib/supermodel.rb
View
64 lib/active_model/serialize_options.rb
@@ -1,64 +0,0 @@
-module ActiveModel
- module SerializeOptions
- class Options
- def initialize
- @options = {}
- end
-
- %w( only except methods ).each do |method|
- class_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{method}(*args)
- @options[:#{method}] ||= []
- @options[:#{method}] |= args
- end
- EOS
- end
-
- # We do not want to override include
- def includes(*args)
- @options[:include] ||= []
- @options[:include] |= args
- end
-
- def merge(opts = nil)
- options = @options.dup
- (opts || {}).each do |key, value|
- options[key] ||= []
- options[key] |= Array(value)
- end
- options
- end
-
- def replace(opts)
- @options.replace(opts)
- end
- end
-
- module Model
- def self.included(base)
- base.send :include, InstanceMethods
- base.send :extend, ClassMethods
- end
- end
-
- module InstanceMethods
- def serializable_hash(options = nil)
- options = self.class.serialize_options.merge(options)
- super(options)
- end
- end
-
- module ClassMethods
- def serialize_options(&block)
- @serialize_options ||= Options.new
- @serialize_options.instance_eval(&block) if block_given?
- @serialize_options
- end
-
- def serialize_options=(options)
- @serialize_options ||= Options.new
- @serialize_options.replace(options)
- end
- end
- end
-end
View
4 lib/supermodel.rb
@@ -33,8 +33,4 @@ module SuperModel
autoload :Dirty, "supermodel/dirty"
autoload :Redis, "supermodel/redis"
autoload :Base, "supermodel/base"
-end
-
-module ActiveModel
- autoload :SerializeOptions, "active_model/serialize_options"
end

0 comments on commit f41eaae

Please sign in to comment.