Module: Virtus::Extensions::Methods
- Included in:
- ClassMethods
- Defined in:
- lib/virtus/extensions.rb
Instance Method Summary collapse
-
#attribute(name, type = nil, options = {}) ⇒ self
Defines an attribute on an object’s class or instance.
- #values(&block) ⇒ Object
Instance Method Details
#attribute(name, type = nil, options = {}) ⇒ self
Defines an attribute on an object’s class or instance
63 64 65 66 67 |
# File 'lib/virtus/extensions.rb', line 63 def attribute(name, type = nil, = {}) assert_valid_name(name) attribute_set << Attribute.build(type, .merge(:name => name)) self end |
#values(&block) ⇒ Object
72 73 74 75 76 |
# File 'lib/virtus/extensions.rb', line 72 def values(&block) private :attributes= if instance_methods.include?(:attributes=) yield include(::Equalizer.new(*attribute_set.map(&:name))) end |