diff --git a/lib/schema_registry/maybe.rb b/lib/schema_registry/maybe.rb index d3b412b..2ca1182 100644 --- a/lib/schema_registry/maybe.rb +++ b/lib/schema_registry/maybe.rb @@ -43,7 +43,7 @@ module ClassMethods # Maybe.strip({ a: Maybe.from(1), b: Maybe.empty, c: Maybe.from(3) }) # # => { a: 1, c: 3 } # ``` - def strip(input) # rubocop:disable Metrics/PerceivedComplexity + def self.strip(input) # rubocop:disable Metrics/PerceivedComplexity input .reject { |_key, value| value == empty } .to_h do |key, value| @@ -63,21 +63,21 @@ def strip(input) # rubocop:disable Metrics/PerceivedComplexity # Creates an empty instance. sig { returns(Absent) } - def empty - Absent.new(nil) + def self.empty + Absent.new end sig { returns(Absent) } # Creates an empty instance. # Alias for self.empty - def none + def self.none empty end sig { returns(Absent) } # Creates an empty instance. # Alias for self.empty - def absent + def self.absent empty end @@ -89,7 +89,7 @@ def absent end # Creates an instance containing the specified value. # Necessary to make this work with sorbet-coerce - def new(value) + def self.new(value) from(value) end @@ -99,7 +99,7 @@ def new(value) .returns(Maybe[T.all(BasicObject, T.type_parameter(:Value))]) end # Creates an instance containing the specified value. - def from(value) + def self.from(value) Present[T.all(BasicObject, T.type_parameter(:Value))].new(value) end end diff --git a/lib/schema_registry/maybe/present.rb b/lib/schema_registry/maybe/present.rb index 170953f..21808e3 100644 --- a/lib/schema_registry/maybe/present.rb +++ b/lib/schema_registry/maybe/present.rb @@ -66,7 +66,7 @@ def when_absent(&_block) def filter(&_block) return self if yield value - Absent.new(value) + Absent.new end sig(:final) do