Skip to content

Commit

Permalink
implement compare/3 and compare/2 for nils
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Mar 5, 2021
1 parent 7a83ab9 commit 5f7421c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.0 - 2021-03-05

### Fixed

- Added implementations for `Fob.PageBreak.compare/3` and `compare/2` for `nil`s

## 0.3.0 - 2021-03-04

### Added
Expand Down
6 changes: 6 additions & 0 deletions lib/fob/page_break.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ defmodule Fob.PageBreak do
compare(add_query_info(a, query), add_query_info(b, query))
end

def compare(nil, _, _), do: :lt
def compare(_, nil, _), do: :gt

def compare(a, b)

def compare(a, b) when is_list(a) and is_list(b) and length(a) == length(b) do
Expand All @@ -52,6 +55,9 @@ defmodule Fob.PageBreak do
_compare(a, b, direction)
end

def compare(nil, _), do: :lt
def compare(_, nil), do: :gt

defp _compare(a, b, direction)

defp _compare(value, value, _direction), do: :eq
Expand Down

0 comments on commit 5f7421c

Please sign in to comment.