module Virtus::InstanceMethods::MassAssignment
Public Instance Methods
attributes()
click to toggle source
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
# File lib/virtus/instance_methods.rb, line 41 def attributes attribute_set.get(self) end
attributes=(attributes)
click to toggle source
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
# File lib/virtus/instance_methods.rb, line 70 def attributes=(attributes) attribute_set.set(self, attributes) end