Module: Virtus::ClassMethods

Includes:
Extensions
Defined in:
lib/virtus/class_methods.rb

Overview

Class methods that are added when you include Virtus

Constant Summary

Constants included from Extensions

Extensions::INVALID_WRITER_METHODS, Extensions::WRITER_METHOD_REGEXP

Instance Method Summary collapse

Methods included from Extensions

#allowed_writer_methods, #attribute

Instance Method Details

#attribute_setAttributeSet

Returns all the attributes defined on a Class

Examples:

class User
  include Virtus

  attribute :name, String
  attribute :age,  Integer
end

User.attributes  # =>

TODO: implement inspect so the output is not cluttered - solnic

Returns:



41
42
43
44
45
46
47
# File 'lib/virtus/class_methods.rb', line 41

def attribute_set
  return @attribute_set if defined?(@attribute_set)
  superclass  = self.superclass
  method      = __method__
  parent      = superclass.public_send(method) if superclass.respond_to?(method)
  @attribute_set = AttributeSet.new(parent)
end

#attributesObject

Deprecated.

See Also:

  • attribute_set


54
55
56
57
# File 'lib/virtus/class_methods.rb', line 54

def attributes
  warn "#{self}.attributes is deprecated. Use #{self}.attribute_set instead: #{caller.first}"
  attribute_set
end