Module | Virtus::InstanceMethods |
In: |
lib/virtus/instance_methods.rb
|
Instance methods that are added when you include Virtus
Returns a value of the attribute with the given name
@example
class User include Virtus attribute :name, String end user = User.new(:name => 'John') user[:name] # => "John"
@param [Symbol] name
a name of an attribute
@return [Object]
a value of an attribute
@api public
Sets a value of the attribute with the given name
@example
class User include Virtus attribute :name, String end user = User.new user[:name] = "John" # => "John" user.name # => "John"
@param [Symbol] name
a name of an attribute
@param [Object] value
a value to be set
@return [Object]
the value set on an object
@api public
Freeze object
@return [self]
@api public
@example
class User include Virtus attribute :name, String attribute :age, Integer end user = User.new(:name => 'John', :age => 28) user.frozen? # => false user.freeze user.frozen? # => true
@api public