Module: Virtus::ValueObject::InstanceMethods
- Defined in:
- lib/virtus/value_object.rb
Constant Summary collapse
- FILTER_NONE =
the #get_attributes method accept a Proc object that will filter out an attribute when the block returns false. the ValueObject needs all the attributes, so we allow every attribute.
proc { true }
Instance Method Summary collapse
-
#clone ⇒ self
(also: #dup)
ValueObjects are immutable and can’t be cloned.
- #initialize(attributes = {}) ⇒ Object
- #with(attribute_updates) ⇒ Object
Instance Method Details
#clone ⇒ self Also known as: dup
ValueObjects are immutable and can’t be cloned
They always represent the same value
70 71 72 |
# File 'lib/virtus/value_object.rb', line 70 def clone self end |
#initialize(attributes = {}) ⇒ Object
51 52 53 |
# File 'lib/virtus/value_object.rb', line 51 def initialize(attributes = {}) set_attributes(attributes) end |
#with(attribute_updates) ⇒ Object
55 56 57 |
# File 'lib/virtus/value_object.rb', line 55 def with(attribute_updates) self.class.new(get_attributes(&FILTER_NONE).merge(attribute_updates)) end |