Module Virtus::InstanceMethods::MassAssignment
In: lib/virtus/instance_methods.rb

Methods

Public Instance methods

Returns a hash of all publicly accessible attributes

@example

  class User
    include Virtus

    attribute :name, String
    attribute :age,  Integer
  end

  user = User.new(:name => 'John', :age => 28)
  user.attributes  # => { :name => 'John', :age => 28 }

@return [Hash]

@api public

Mass-assign attribute values

Keys in the attributes param can be symbols or strings. All referenced Attribute writer methods will be called. Non-attribute setter methods on the receiver will be called.

@example

  class User
    include Virtus

    attribute :name, String
    attribute :age,  Integer
  end

  user = User.new
  user.attributes = { :name => 'John', 'age' => 28 }

@param [to_hash] attributes

  a hash of attribute names and values to set on the receiver

@return [Hash]

@api public

to_h()

Alias for attributes

to_hash()

Alias for attributes

[Validate]