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

Added update_or_create method #4

Merged
merged 4 commits into from Jul 28, 2017

Conversation

jamesbowles
Copy link
Contributor

This new method allows us to use multiple keys to identify records, it replaces the implementation of .refresh.

Fixes #2

This new method allows us to use multiple keys to identify records, it replaces the implementation of `.refresh`.

Fixes abletech#2
README.md Outdated
Easy::ReferenceData.refresh User, :system_code, 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com'
Easy::ReferenceData.refresh User, :system_code, 'fred', name: 'Fred Schmitt', email: 'fred.schmitt@mailinator.com'
Easy::ReferenceData.refresh User, :system_code, 'bert', name: 'Bert Symthe', email: 'bert.smythe@mailinator.com'
Easy::ReferenceData.update_or_create User, system_code: 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com', keys: [:system_code]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these examples be adjusted to separate the keys option from the User attributes? Eg:

Easy::ReferenceData.update_or_create User, {system_code: 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com'}, keys: [:system_code]

At the moment, it looks as if keys is just another attribute of User.

puts "..creating #{clazz}(#{unique_attribute_value})"
elsif record.changed?
puts "..updating #{clazz}(#{unique_attribute_value})"
puts "..creating #{clazz}(#{attributes.slice(*unique_attribute_keys)})"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment, these puts statements are all writing to $stdout be default. I believe Unix convention is for these sort of debug/progress messages to write to $stderr. I suggest we change this at the same time.

@@ -1,5 +1,5 @@
module Easy
module ReferenceData
VERSION = "0.1.2"
VERSION = "0.2.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should just go straight to version 1.0.0?

Copy link
Member

@nigelramsay nigelramsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor remarks. Looks good though!

@jamesbowles jamesbowles merged commit 09e0411 into abletech:master Jul 28, 2017
@jamesbowles jamesbowles deleted the composite_keys branch July 28, 2017 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants