Skip to content

Commit

Permalink
Add contributors, add debugging infos in the manual
Browse files Browse the repository at this point in the history
  • Loading branch information
Yacine Petitprez committed Jul 3, 2018
1 parent eb9f653 commit 68ea6ed
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Core developer

- Yacine Petitprez ([email protected])

## Thanks to

- 007lva ([email protected])
- Jeremy Woertink ([email protected])
- Matthias Zauner ([email protected])
- Russ Smith ([email protected])
- Troy A. Sornson ([email protected])

For contributing to a better ~world~ ORM.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ You don't want to use Clear if:
- [Source Code](https://github.com/anykeyh/clear)
- [A simple example is available here](https://github.com/anykeyh/clear/blob/master/sample/wiki/getting_started.cr)
- [Changelog](https://github.com/anykeyh/clear/blob/master/CHANGELOG.md)


- [Credits](https://github.com/anykeyh/clear/tree/master/CONTRIBUTORS.md)

## Getting started

Expand Down
1 change: 1 addition & 0 deletions manual/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ If you're in hurry and already at ease with Active Record pattern, a simple stan
- [Polymorphism](model/Polymorphism.md)
- [Different database connections](model/MultiConnection.md)
- [Column data type management](model/TypeConversion.md)
- [SQL Debugging Info](model/DebuggingInfo.md)

## Querying

Expand Down
36 changes: 36 additions & 0 deletions manual/model/DebuggingInfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#### Inspection

We've reimplemented `inspect` on models, to offer debugging insights:

```text
pp post # => #<Post:0x10c5f6720
@attributes={},
@cache=
#<Clear::Model::QueryCache:0x10c6e8100
@cache={},
@cache_activation=Set{}>,
@content_column=
"...",
@errors=[],
@id_column=38,
@persisted=true,
@published_column=true,
@read_only=false,
@title_column="Lorem ipsum torquent inceptos"*,
@user_id_column=5>
```

In this case, the `*` means a column is changed and the object is dirty and must
be saved on the database.

#### SQL Logging

Clear is offering SQL logging tools, with SQL syntax colorizing in your terminal.
For activation, simply setup the logger to `DEBUG` level

```
Clear.logger.level = ::Logger::DEBUG
```

Also, Clear will log all query made, and when exception will show you the last query
in your terminal.
6 changes: 5 additions & 1 deletion src/clear/extensions/enum/enum.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Clear
# ```
macro enum(name, *values)
struct {{name.id}} < ::Clear::Enum
AUTHORIZED_VALUES = {} of String => {{name.id}}
private AUTHORIZED_VALUES = {} of String => {{name.id}}

{% for i in values %}
{{i.camelcase.id}} = {{name.id}}.new("{{i.id}}")
Expand All @@ -75,6 +75,10 @@ module Clear
AUTHORIZED_VALUES.values
end

def self.valid?(x)
AUTHORIZED_VALUES[x]?
end

macro finished
module ::Clear::Model::Converter::\{{@type}}Converter
def self.to_column(x) : ::\{{@type}}?
Expand Down

0 comments on commit 68ea6ed

Please sign in to comment.