Class: Errgonomic::Option::Some
- Defined in:
- lib/errgonomic/option.rb,
lib/errgonomic/rails/active_record_optional.rb
Overview
A belongs_to declared touch: true reads the associated record back through the public reader after a save, then asks it to touch itself.
Constant Summary
Constants inherited from Any
Any::NUDGED, Any::RUST_SPELLINGS
Instance Method Summary collapse
-
#initialize(value) ⇒ Some
constructor
A Some is a value, not a slot: nothing outside reads the inner value without handling the None branch, and nothing swaps it out from under another reference or a Hash key.
-
#inspect ⇒ Object
Render like Rust's Debug, delegating to the inner value's inspect so nesting stays unambiguous.
- #none? ⇒ Boolean
- #some? ⇒ Boolean
Methods inherited from Any
#!=, #<=>, #==, #===, #and, #and_then, #as_json, #blank?, #blank_or, #blank_or_else, #blank_or_raise!, #deconstruct, #each, #eql?, #expect!, #filter, #flatten, #hash, #map, #map_or, #map_or_else, #method_missing, #none_or, #ok_or, #ok_or_else, #or, #or_else, #presence, #present?, #present_or, #present_or_else, #present_or_raise!, #pretty_print, #respond_to_missing?, #some_and, #tap_some, #to_a, #to_json, #to_option, #to_s, #try, #try!, #unwrap!, #unwrap_or, #unwrap_or_else, #xor, #zip, #zip_with
Constructor Details
#initialize(value) ⇒ Some
A Some is a value, not a slot: nothing outside reads the inner value without handling the None branch, and nothing swaps it out from under another reference or a Hash key.
963 964 965 966 967 |
# File 'lib/errgonomic/option.rb', line 963 def initialize(value) super() @value = value freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Errgonomic::Option::Any
Instance Method Details
#inspect ⇒ Object
Render like Rust's Debug, delegating to the inner value's inspect so nesting stays unambiguous.
985 986 987 |
# File 'lib/errgonomic/option.rb', line 985 def inspect "Some(#{value.inspect})" end |
#none? ⇒ Boolean
973 974 975 |
# File 'lib/errgonomic/option.rb', line 973 def none? false end |
#some? ⇒ Boolean
969 970 971 |
# File 'lib/errgonomic/option.rb', line 969 def some? true end |