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

not able to set a key using force: true #24

Open
joecabezas opened this issue Oct 3, 2018 · 1 comment
Open

not able to set a key using force: true #24

joecabezas opened this issue Oct 3, 2018 · 1 comment

Comments

@joecabezas
Copy link
Contributor

what I am missing?

Stasche.set(joe_rules_backtest: 1, force: true)
Stasche::Store::KeyAlreadyExistsError: Key checkr-stasche:joe_rules_backtest already set in stasche. Use `force: true` to override.
from /bundle/gems/stasche-1.3.3/lib/stasche/store/s3.rb:26:in `set'
@joecabezas
Copy link
Contributor Author

joecabezas commented Oct 3, 2018

so it seems like in code:

def set(values, options = {})
last_value = values.inject(nil) do |_, (key, value)|
json = { value: value }.to_json
encrypted_json = encrypt(json)
store.set("#{namespace}:#{key}", encrypted_json, options)
key
end

both values, and options are positional arguments that both of them are expected to be hashes, this is why Stasche.set(joe_rules_backtest: 1, force: true) does nto work .and it needs to separate the arguments using brackets like:

Stasche.set({joe_rules_backtest: 1}, {force: true})

hope this is useful to anyone in the future, for now I added a spec to include this case:

related PR:
#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant