===

===(other) Instance Public methods Equivalent to #==. class BlogPost extend ActiveModel::Naming end BlogPost.model_name === 'BlogPost' # => true BlogPost.model_name === 'Blog Post' # => false

==

==(other) Instance Public methods Equivalent to String#==. Returns true if the class name and other are equal, otherwise false. class BlogPost extend ActiveModel::Naming end BlogPost.model_name == 'BlogPost' # => true BlogPost.model_name == 'Blog Post' # => false

<=>

==(other) Instance Public methods Equivalent to String#<=>. class BlogPost extend ActiveModel::Naming end BlogPost.model_name <=> 'BlogPost' # => 0 BlogPost.model_name <=> 'Blog' # => 1 BlogPost.model_name <=> 'BlogPosts' # => -1

!~

!~(regexp) Instance Public methods Equivalent to String#!~. Match the class name against the given regexp. Returns true if there is no match, otherwise false. class BlogPost extend ActiveModel::Naming end BlogPost.model_name !~ /Post/ # => false BlogPost.model_name !~ /\d/ # => true

new

new(klass, namespace = nil, name = nil) Class Public methods Returns a new ActiveModel::Name instance. By default, the namespace and name option will take the namespace and name of the given class respectively. module Foo class Bar end end ActiveModel::Name.new(Foo::Bar).to_s # => "Foo::Bar"

persisted?

persisted?() Instance Public methods Indicates if the model is persisted. Default is false. class Person include ActiveModel::Model attr_accessor :id, :name end person = Person.new(id: 1, name: 'bob') person.persisted? # => false

new

new(params={}) Class Public methods Initializes a new model with the given params. class Person include ActiveModel::Model attr_accessor :name, :age end person = Person.new(name: 'bob', age: '18') person.name # => "bob" person.age # => 18

test_to_partial_path

test_to_partial_path() Instance Public methods Responds to to_partial_path Returns a string giving a relative path. This is used for looking up partials. For example, a BlogPost model might return âblog_posts/blog_postâ

test_to_param

test_to_param() Instance Public methods Responds to to_param Returns a string representing the object's key suitable for use in URLs or nil if model.persisted? is false. Implementers can decide to either raise an exception or provide a default in case the record uses a composite primary key. There are no tests for this behavior in lint because it doesn't make sense to force any of the possible implementation strategies on the implementer. However, if the resource is not persisted?,

test_to_key

test_to_key() Instance Public methods Responds to to_key Returns an Enumerable of all (primary) key attributes or nil if model.persisted? is false. This is used by dom_id to generate unique ids for the object.