Class: Errgonomic::Option::Some
- Defined in:
- lib/errgonomic/option.rb,
lib/errgonomic/rails/active_record_optional.rb
Overview
Delegate ActiveRecord lifecycle checks to the wrapped record, so a Some can stand in for its record during persistence.
Constant Summary
Constants inherited from Any
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Some
constructor
A new instance of Some.
-
#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, #blank?, #deconstruct, #eql?, #expect!, #filter, #flatten, #hash, #map, #map_or, #map_or_else, #method_missing, #none_or, #ok, #ok_or, #ok_or_else, #or, #or_else, #present?, #pretty_print, #respond_to_missing?, #some_and, #tap_some, #to_a, #to_json, #to_s, #unwrap!, #unwrap_or, #unwrap_or_else, #xor, #zip, #zip_with
Constructor Details
#initialize(value) ⇒ Some
Returns a new instance of Some.
513 514 515 516 |
# File 'lib/errgonomic/option.rb', line 513 def initialize(value) super() @value = value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Errgonomic::Option::Any
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
511 512 513 |
# File 'lib/errgonomic/option.rb', line 511 def value @value end |
Instance Method Details
#inspect ⇒ Object
Render like Rust's Debug, delegating to the inner value's inspect so nesting stays unambiguous.
534 535 536 |
# File 'lib/errgonomic/option.rb', line 534 def inspect "Some(#{value.inspect})" end |
#none? ⇒ Boolean
522 523 524 |
# File 'lib/errgonomic/option.rb', line 522 def none? false end |
#some? ⇒ Boolean
518 519 520 |
# File 'lib/errgonomic/option.rb', line 518 def some? true end |