Module: ActiveRecordOptionShim
- Defined in:
- lib/errgonomic/rails/active_record_optional.rb
Overview
Teach ActiveRecord type casting to unwrap Options: a Some casts as its inner value, a None casts as nil.
Instance Method Summary collapse
Instance Method Details
#type_cast(value) ⇒ Object
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/errgonomic/rails/active_record_optional.rb', line 232 def type_cast(value) case value when Errgonomic::Option::Some super(value.unwrap!) when Errgonomic::Option::None super(nil) else super end end |