-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add repository timestamps #169
Conversation
# | ||
# class User | ||
# include Lotus::Entity | ||
# attributes :timestamps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about having a separate method, for example add_timestamps
instead? IMHO I think we should allow users to have attribute with naming 'timestamps'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have 2 different ways in defining timestamp? For repo, we do include Lotus::Repository::Timestamps
why don't we do the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joneslee85 separate method is good solution, you're right.
But what do you think about dynamical creation of #created_at and #updated_at? After all, 3 places for declaration timestamps is a little uncomfortable.
Users can declare it in repository and in maps (inside collection). After an entity will be persisted and returned, they'll be have timestamps.
Also I think about make them read-only for users. What do you think?
@joneslee85 thanks for your comments. |
btw, #170 will be very useful here for checking need update #updated_at or not. Thereby, I'll wait till it merged (or declined for some reason) and use it functionality. |
@dsnipe can you please rebase? |
ba0e2a3
to
7a7c6e3
Compare
@joneslee85 done |
@dsnipe thanks for the update, looking forward to seeing your 2nd PR merge |
@joneslee85, @jodosha
|
let(:article) { Article.new(title: 'New article with timestamp') } | ||
let(:persisted_article) { ArticleRepository.create(article) } | ||
|
||
it '#created_at' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using describe
instead of it
here? And describe what it does with it
, for example: it 'touches created_at attribute'
@dsnipe thanks for this work
Atm, I have no strong opinion on using global configuration block. @jodosha please weight in your opinion on this However, I don't think doing magic with entity through repository is a good idea. I want to keep Entity free from Repository knowledge and the other way around.
Are you implying about that upon calling |
@joneslee85 thanks for the review
@jodosha write about it here: #172 (comment)
Same for me actually.
Yep. It tap |
@dsnipe I think improvement on top this feature can be done as separate PR. |
@joneslee85 agree with you, so leave this PR as it is. |
dc68772
to
819712c
Compare
👍 |
# timestamps | ||
# end | ||
# end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this empty line
Finally, I freed some time to continue :) |
819712c
to
cbf954f
Compare
cbf954f
to
fb671d4
Compare
fb671d4
to
fa2b3f5
Compare
PR based on discussion in #134