Permalink
Browse files

Kill AMo ivar attributes helper

  • Loading branch information...
josh committed Jul 21, 2009
1 parent e7a2496 commit 2685d93b0728b647b6f49f3e1802c779d5fb9867
@@ -27,7 +27,6 @@
module ActiveModel
autoload :APICompliant, 'active_model/api_compliant'
- autoload :Attributes, 'active_model/attributes'
autoload :Base, 'active_model/base'
autoload :DeprecatedErrorMethods, 'active_model/deprecated_error_methods'
autoload :Errors, 'active_model/errors'
@@ -1,25 +0,0 @@
-require 'active_support/core_ext/object/instance_variables'
-
-module ActiveModel
- module Attributes
- def self.append_features(base)
- unless base.instance_methods.include?('attributes')
- super
- else
- false
- end
- end
-
- def attributes
- instance_values
- end
-
- def read_attribute(attr_name)
- instance_variable_get(:"@#{attr_name}")
- end
-
- def write_attribute(attr_name, value)
- instance_variable_set(:"@#{attr_name}", value)
- end
- end
-end
@@ -5,7 +5,6 @@ module ActiveModel
module Serializers
module JSON
extend ActiveSupport::Concern
- include ActiveModel::Attributes
included do
extend ActiveModel::Naming
@@ -5,7 +5,6 @@ module ActiveModel
module Serializers
module Xml
extend ActiveSupport::Concern
- include ActiveModel::Attributes
class Serializer < ActiveModel::Serializer #:nodoc:
class Attribute #:nodoc:
@@ -1,30 +0,0 @@
-require 'cases/helper'
-
-class AttributesTest < ActiveModel::TestCase
- class Person
- include ActiveModel::Attributes
- attr_accessor :name
- end
-
- test "reads attribute" do
- p = Person.new
- assert_equal nil, p.read_attribute(:name)
-
- p.name = "Josh"
- assert_equal "Josh", p.read_attribute(:name)
- end
-
- test "writes attribute" do
- p = Person.new
- assert_equal nil, p.name
-
- p.write_attribute(:name, "Josh")
- assert_equal "Josh", p.name
- end
-
- test "returns all attributes" do
- p = Person.new
- p.name = "Josh"
- assert_equal({"name" => "Josh"}, p.attributes)
- end
-end
@@ -3,6 +3,10 @@
class Contact
include ActiveModel::Serializers::JSON
+
+ def attributes
+ instance_values
+ end
end
class JsonSerializationTest < ActiveModel::TestCase
@@ -3,6 +3,10 @@
class Contact
include ActiveModel::Serializers::Xml
+
+ def attributes
+ instance_values
+ end
end
class XmlSerializationTest < ActiveModel::TestCase

0 comments on commit 2685d93

Please sign in to comment.