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

Adding new has_key_for? method to params #500

Merged
merged 2 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/operations/nested_save_operation_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ private class NestedParams
def nested_file(key)
raise "Not implemented"
end

def has_key_for?(operation : Avram::Operation.class | Avram::SaveOperation.class) : Bool
nested?(operation.param_key).any?
end
end

describe "Avram::SaveOperation with nested operation" do
Expand Down
1 change: 1 addition & 0 deletions src/avram/paramable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module Avram::Paramable
abstract def nested(key : String) : Hash(String, String)
abstract def get?(key : String)
abstract def get(key : String)
abstract def has_key_for?(operation : Avram::Operation.class | Avram::SaveOperation.class) : Bool
end
4 changes: 4 additions & 0 deletions src/avram/params.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ class Avram::Params
def nested_file(key) : Hash(String, String)
@hash
end

def has_key_for?(operation : Avram::Operation.class | Avram::SaveOperation.class) : Bool
nested?(operation.param_key).any?
end
end