Skip to content

Commit

Permalink
define class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrias committed Aug 21, 2024
1 parent 8ea2aee commit 329d50e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/schema_registry/maybe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_registry/maybe/present.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 329d50e

Please sign in to comment.