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
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/errgonomic/rails/active_record_optional.rb', line 95 def type_cast(value) case value when Errgonomic::Option::Some super(value.unwrap!) when Errgonomic::Option::None super(nil) else super end end |