Module: Virtus::ClassMethods
- Defined in:
- lib/virtus/class_methods.rb
Overview
Class methods that are added when you include Virtus
Instance Method Summary collapse
-
#attribute(*args) ⇒ self
Defines an attribute on an object’s class.
-
#attributes ⇒ AttributeSet
Returns all the attributes defined on a Class.
Instance Method Details
#attribute(*args) ⇒ self
Defines an attribute on an object’s class
49 50 51 52 53 54 |
# File 'lib/virtus/class_methods.rb', line 49 def attribute(*args) attribute = Attribute.build(*args) attribute.define_accessor_methods(virtus_attributes_accessor_module) virtus_add_attribute(attribute) self end |
#attributes ⇒ AttributeSet
Returns all the attributes defined on a Class
73 74 75 76 77 78 79 |
# File 'lib/virtus/class_methods.rb', line 73 def attributes return @attributes if defined?(@attributes) superclass = self.superclass method = __method__ parent = superclass.send(method) if superclass.respond_to?(method) @attributes = AttributeSet.new(parent) end |