Permalink
Browse files

Rename ActiveModel::Model to ActiveModel::BasicModel

  • Loading branch information...
1 parent 72e6fb0 commit fe5dd0a00611e71686a6f5264a0e3b95781b2aa8 @guilleiguaran committed Oct 29, 2012
@@ -45,7 +45,7 @@
class User < ActiveRecord::Base; end
class Person
- include ActiveModel::Model
+ include ActiveModel::BasicModel
include ActiveModel::AttributeMethods
include ActiveModel::Serializers::JSON
@@ -70,7 +70,7 @@
* `ConfirmationValidator` error messages will attach to `:#{attribute}_confirmation` instead of `attribute` *Brian Cardarella*
-* Added ActiveModel::Model, a mixin to make Ruby objects work with AP out of box *Guillermo Iguaran*
+* Added ActiveModel::BasicModel, a mixin to make Ruby objects work with AP out of box *Guillermo Iguaran*
* `AM::Errors#to_json`: support `:full_messages` parameter *Bogdan Gusiev*
@@ -14,10 +14,10 @@ Model solves this by defining an explicit API. You can read more about the
API in ActiveModel::Lint::Tests.
Active Model provides a default module that implements the basic API required
-to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>.
+to integrate with Action Pack out of the box: <tt>ActiveModel::BasicModel</tt>.
class Person
- include ActiveModel::Model
+ include ActiveModel::BasicModel
attr_accessor :name, :age
validates_presence_of :name
@@ -30,7 +30,7 @@ to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>.
It includes model name introspections, conversions, translations and
validations, resulting in a class suitable to be used with Action Pack.
-See <tt>ActiveModel::Model</tt> for more examples.
+See <tt>ActiveModel::BasicModel</tt> for more examples.
Active Model also provides the following functionality to have ORM-like
behavior out of the box:
@@ -29,14 +29,14 @@ module ActiveModel
extend ActiveSupport::Autoload
autoload :AttributeMethods
+ autoload :BasicModel
autoload :BlockValidator, 'active_model/validator'
autoload :Callbacks
autoload :Conversion
autoload :Dirty
autoload :EachValidator, 'active_model/validator'
autoload :ForbiddenAttributesProtection
autoload :Lint
- autoload :Model
autoload :DeprecatedMassAssignmentSecurity
autoload :Name, 'active_model/naming'
autoload :Naming
@@ -11,20 +11,20 @@ module ActiveModel
# A minimal implementation could be:
#
# class Person
- # include ActiveModel::Model
+ # include ActiveModel::BasicModel
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => 'bob'
# person.age # => 18
#
- # Note that, by default, <tt>ActiveModel::Model</tt> implements <tt>persisted?</tt>
+ # Note that, by default, <tt>ActiveModel::BasicModel</tt> implements <tt>persisted?</tt>
# to return +false+, which is the most common case. You may want to override
# it in your class to simulate a different scenario:
#
# class Person
- # include ActiveModel::Model
+ # include ActiveModel::BasicModel
# attr_accessor :id, :name
#
# def persisted?
@@ -40,7 +40,7 @@ module ActiveModel
# happen.
#
# class Person
- # include ActiveModel::Model
+ # include ActiveModel::BasicModel
# attr_accessor :id, :name, :omg
#
# def initialize(attributes={})
@@ -53,9 +53,9 @@ module ActiveModel
# person.omg # => true
#
# For more detailed information on other functionalities available, please
- # refer to the specific modules included in <tt>ActiveModel::Model</tt>
+ # refer to the specific modules included in <tt>ActiveModel::BasicModel</tt>
# (see below).
- module Model
+ module BasicModel
def self.included(base) #:nodoc:
base.class_eval do
extend ActiveModel::Naming
@@ -68,7 +68,7 @@ def self.included(base) #:nodoc:
# Initializes a new model with the given +params+.
#
# class Person
- # include ActiveModel::Model
+ # include ActiveModel::BasicModel
# attr_accessor :name, :age
# end
#
@@ -84,7 +84,7 @@ def initialize(params={})
# Indicates if the model is persisted. Default is +false+.
#
# class Person
- # include ActiveModel::Model
+ # include ActiveModel::BasicModel
# attr_accessor :id, :name
# end
#
@@ -3,24 +3,24 @@
class ModelTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests
- class BasicModel
- include ActiveModel::Model
- attr_accessor :attr
+ class Racer
+ include ActiveModel::BasicModel
+ attr_accessor :name
end
def setup
- @model = BasicModel.new
+ @model = Racer.new
end
def test_initialize_with_params
- object = BasicModel.new(:attr => "value")
- assert_equal object.attr, "value"
+ racer = Racer.new(:name => "DHH")
+ assert_equal racer.name, "DHH"
end
def test_initialize_with_nil_or_empty_hash_params_does_not_explode
assert_nothing_raised do
- BasicModel.new()
- BasicModel.new({})
+ Racer.new()
+ Racer.new({})
end
end
end
@@ -756,7 +756,7 @@ Active Model
class User < ActiveRecord::Base; end
class Person
- include ActiveModel::Model
+ include ActiveModel::BasicModel
include ActiveModel::AttributeMethods
include ActiveModel::Serializers::JSON
@@ -780,7 +780,7 @@ Active Model
* `ConfirmationValidator` error messages will attach to `:#{attribute}_confirmation` instead of `attribute`.
-* Added `ActiveModel::Model`, a mixin to make Ruby objects work with Action Pack out of the box.
+* Added `ActiveModel::BasicModel`, a mixin to make Ruby objects work with Action Pack out of the box.
* `ActiveModel::Errors#to_json` supports a new parameter `:full_messages`.

0 comments on commit fe5dd0a

Please sign in to comment.