aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-09 23:39:10 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-09 23:39:10 +0000
commitddf385a55445f22221d64c9ead43470e2c56af2e (patch)
treef10e4c44f22f15fe416a2368b8d5054f922b6782 /activerecord/lib/active_record
parent250f871b9012fc461f83d7767cc49fe40dbbc104 (diff)
downloadrails-ddf385a55445f22221d64c9ead43470e2c56af2e.tar.gz
rails-ddf385a55445f22221d64c9ead43470e2c56af2e.tar.bz2
rails-ddf385a55445f22221d64c9ead43470e2c56af2e.zip
Remove the wrapping feature that was never actually turned into something real [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7440 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/wrappers/yaml_wrapper.rb15
-rw-r--r--activerecord/lib/active_record/wrappings.rb58
2 files changed, 0 insertions, 73 deletions
diff --git a/activerecord/lib/active_record/wrappers/yaml_wrapper.rb b/activerecord/lib/active_record/wrappers/yaml_wrapper.rb
deleted file mode 100644
index 74f40a507c..0000000000
--- a/activerecord/lib/active_record/wrappers/yaml_wrapper.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'yaml'
-
-module ActiveRecord
- module Wrappings #:nodoc:
- class YamlWrapper < AbstractWrapper #:nodoc:
- def wrap(attribute) attribute.to_yaml end
- def unwrap(attribute) YAML::load(attribute) end
- end
-
- module ClassMethods #:nodoc:
- # Wraps the attribute in Yaml encoding
- def wrap_in_yaml(*attributes) wrap_with(YamlWrapper, attributes) end
- end
- end
-end \ No newline at end of file
diff --git a/activerecord/lib/active_record/wrappings.rb b/activerecord/lib/active_record/wrappings.rb
deleted file mode 100644
index e8b6018850..0000000000
--- a/activerecord/lib/active_record/wrappings.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-module ActiveRecord
- # A plugin framework for wrapping attribute values before they go in and unwrapping them after they go out of the database.
- # This was intended primarily for YAML wrapping of arrays and hashes, but this behavior is now native in the Base class.
- # So for now this framework is laying dormant until a need pops up.
- module Wrappings #:nodoc:
- module ClassMethods #:nodoc:
- def wrap_with(wrapper, *attributes)
- [ attributes ].flat.each { |attribute| wrapper.wrap(attribute) }
- end
- end
-
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- class AbstractWrapper #:nodoc:
- def self.wrap(attribute, record_binding) #:nodoc:
- %w( before_save after_save after_initialize ).each do |callback|
- eval "#{callback} #{name}.new('#{attribute}')", record_binding
- end
- end
-
- def initialize(attribute) #:nodoc:
- @attribute = attribute
- end
-
- def save_wrapped_attribute(record) #:nodoc:
- if record.attribute_present?(@attribute)
- record.send(
- "write_attribute",
- @attribute,
- wrap(record.send("read_attribute", @attribute))
- )
- end
- end
-
- def load_wrapped_attribute(record) #:nodoc:
- if record.attribute_present?(@attribute)
- record.send(
- "write_attribute",
- @attribute,
- unwrap(record.send("read_attribute", @attribute))
- )
- end
- end
-
- alias_method :before_save, :save_wrapped_attribute #:nodoc:
- alias_method :after_save, :load_wrapped_attribute #:nodoc:
- alias_method :after_initialize, :after_save #:nodoc:
-
- # Overwrite to implement the logic that'll take the regular attribute and wrap it.
- def wrap(attribute) end
-
- # Overwrite to implement the logic that'll take the wrapped attribute and unwrap it.
- def unwrap(attribute) end
- end
- end
-end