Class: BitmaskEnum::NilHandler Private
- Inherits:
-
Object
- Object
- BitmaskEnum::NilHandler
- Defined in:
- lib/bitmask_enum/nil_handler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handles nil attribute values
Instance Method Summary collapse
-
#in_array(array) ⇒ Array
private
Handles nil for an array of values for the attribute.
-
#in_attribute_eval(attribute) ⇒ String
private
Handles nil when evaling the attribute.
-
#initialize(handling_option) ⇒ NilHandler
constructor
private
A new instance of NilHandler.
Constructor Details
#initialize(handling_option) ⇒ NilHandler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of NilHandler.
7 8 9 |
# File 'lib/bitmask_enum/nil_handler.rb', line 7 def initialize(handling_option) @handling_option = handling_option end |
Instance Method Details
#in_array(array) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handles nil for an array of values for the attribute
24 25 26 27 28 29 |
# File 'lib/bitmask_enum/nil_handler.rb', line 24 def in_array(array) select_handling( array, include: ->(arr) { arr << nil } ) end |
#in_attribute_eval(attribute) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handles nil when evaling the attribute
14 15 16 17 18 19 |
# File 'lib/bitmask_enum/nil_handler.rb', line 14 def in_attribute_eval(attribute) select_handling( attribute, include: ->(attrib) { "(self['#{attrib}'] || 0)" } ) end |