Module: Errgonomic::Rails::ActiveModelAttributeWrite
- Defined in:
- lib/errgonomic/rails/active_record_optional.rb
Overview
An attribute writer hands its value to a type cast that has never heard of an Option, and each type fails its own way: a Some is truthy and not one of ActiveModel's FALSE_VALUES, so a wrapped false cast to true. Unwrap before the attribute is built rather than inside the cast, so the value assigned, dirty tracking and the before-type-cast reader all agree on what was assigned. Every writer passes here, as do new, assign_attributes and update.
Instance Method Summary collapse
Instance Method Details
#write_from_user(name, value) ⇒ Object
658 659 660 |
# File 'lib/errgonomic/rails/active_record_optional.rb', line 658 def write_from_user(name, value) super(name, Errgonomic::Rails.unwrap_option(value)) end |