Module: Quant::Attributes::ClassMethods
- Defined in:
- lib/quant/attributes.rb
Instance Method Summary collapse
-
#attribute(name, key: nil, default: nil) ⇒ Object
Define an
attribute
for the class that can optionally be serialized.
Instance Method Details
#attribute(name, key: nil, default: nil) ⇒ Object
Define an attribute
for the class that can optionally be serialized. Works much like an attr_accessor does, but also manages serialization for #to_h and #to_json methods.
An attribute
will result in a same-named instance on the class when it is instantiated and it will set a default value if one is provided.
196 197 198 |
# File 'lib/quant/attributes.rb', line 196 def attribute(name, key: nil, default: nil) Attributes.register(self, name, key, default) end |