Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creditcard docs #48

Merged
merged 2 commits into from
Dec 26, 2017
Merged

Creditcard docs #48

merged 2 commits into from
Dec 26, 2017

Conversation

oyeb
Copy link
Contributor

@oyeb oyeb commented Dec 24, 2017

Why CreditCard.t?

If you read up on how to document Structs, you'll realise that CreditCard, (the module) should not be used as a "type" -- because it is a module, just a bunch of functions. This is related to the confusion between String and String.t.

Composite types must be defined using @type. This helps static analysers like Dialyser to actually perform type-checking.

Real World example

In the excellent swoosh library.

References:
https://www.reddit.com/r/elixir/comments/4v2ss2/help_me_understand_types_in_documentation_specs/
http://elixir-recipes.github.io/types/type-checking/
https://hexdocs.pm/elixir/typespecs.html#user-defined-types
https://stackoverflow.com/questions/29977776/what-does-type-t-module-mean-in-elixir

Other

Notice that,

  • :year and :month are integers!
  • the typespecs now show Gringotts.CreditCard.t, (which is clickable, unlike before!) instead of Gringotts.CreditCard

\# Why `CreditCard.t`?

If you read up on how to document Structs, you'll realise that
`CreditCard`, (the module) should not be used as a "type" -- because it
is a module, just a bunch of functions. This is related to the confusion
between `String` and `String.t`.

Composite types must be defined using @type. This helps static analysers
like Dialyser to actually perform type-checking.

\## Real World example

In the excellent swoosh lib:
https://github.com/swoosh/swoosh/search?utf8=%E2%9C%93&q=type+t+%3A%3A+%25__MODULE__%7Btype&type=

References:
https://www.reddit.com/r/elixir/comments/4v2ss2/help_me_understand_types_in_documentation_specs/
http://elixir-recipes.github.io/types/type-checking/
https://hexdocs.pm/elixir/typespecs.html#user-defined-types
https://stackoverflow.com/questions/29977776/what-does-type-t-module-mean-in-elixir

\# Other

Note that `:year` and `:month` are **integers**!
Notice that the typespecs now show `Gringotts.CreditCard.t`, (which is
clickable, unlike before!) instead of `Gringotts.CreditCard`
@pkrawat1 pkrawat1 merged commit 90362e5 into dev Dec 26, 2017
@pkrawat1 pkrawat1 deleted the creditcard-docs branch December 26, 2017 09:38
oyeb added a commit that referenced this pull request Dec 27, 2017
* I had missed a few `paymentId`s.
* Since #48 is merged, we can use full_name(). Coverage increased for
free :)
pkrawat1 pushed a commit that referenced this pull request Dec 27, 2017
* Refactored code as suggested by credo

Closes #27

* Grouped tests using describe

* Better test descriptions

Removed the pipes and spaces

* Renamed ia CamelCase var.

`paymentId` -> `payment_id`

* Renamed missed CamelCase var, improves CC coverage

* I had missed a few `paymentId`s.
* Since #48 is merged, we can use full_name(). Coverage increased for
free :)

* Ran the elixir 1.6 formatter on Monei

* Fixed unstore test description
* Example cards will expire in 82 yrs :P
pkrawat1 pushed a commit that referenced this pull request Dec 28, 2017
* Defines the CreditCard "type" and adds docs

\# Why `CreditCard.t`?

If you read up on how to document Structs, you'll realise that
`CreditCard`, (the module) should not be used as a "type" -- because it
is a module, just a bunch of functions. This is related to the confusion
between `String` and `String.t`.

Composite types must be defined using @type. This helps static analysers
like Dialyser to actually perform type-checking.

\## Real World example

In the excellent swoosh lib:
https://github.com/swoosh/swoosh/search?utf8=%E2%9C%93&q=type+t+%3A%3A+%25__MODULE__%7Btype&type=

References:
https://www.reddit.com/r/elixir/comments/4v2ss2/help_me_understand_types_in_documentation_specs/
http://elixir-recipes.github.io/types/type-checking/
https://hexdocs.pm/elixir/typespecs.html#user-defined-types
https://stackoverflow.com/questions/29977776/what-does-type-t-module-mean-in-elixir

\# Other

Note that `:year` and `:month` are **integers**!

* Changed @specs in all gateway docs (CreditCard.t)

Notice that the typespecs now show `Gringotts.CreditCard.t`, (which is
clickable, unlike before!) instead of `Gringotts.CreditCard`
pkrawat1 pushed a commit that referenced this pull request Dec 28, 2017
* Refactored code as suggested by credo

Closes #27

* Grouped tests using describe

* Better test descriptions

Removed the pipes and spaces

* Renamed ia CamelCase var.

`paymentId` -> `payment_id`

* Renamed missed CamelCase var, improves CC coverage

* I had missed a few `paymentId`s.
* Since #48 is merged, we can use full_name(). Coverage increased for
free :)

* Ran the elixir 1.6 formatter on Monei

* Fixed unstore test description
* Example cards will expire in 82 yrs :P
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants