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

Force hash keys/values to be particular types? #48

Closed
tfausak opened this issue Aug 19, 2013 · 2 comments
Closed

Force hash keys/values to be particular types? #48

tfausak opened this issue Aug 19, 2013 · 2 comments
Assignees
Milestone

Comments

@tfausak
Copy link
Collaborator

tfausak commented Aug 19, 2013

For hashes with strip: false, it might be useful to specify the types of the keys and/or values. For example:

hash :hash,
  strip: false,
  keys: Symbol,
  values: Integer
@tfausak
Copy link
Collaborator Author

tfausak commented Nov 14, 2013

I think we should support this. Except instead of specifying a class (Symbol), it should behave more like an array and accept a filter (:symbol or symbol).

@tfausak
Copy link
Collaborator Author

tfausak commented Nov 14, 2013

It won't be possible to use the DSL to describe keys or values. They'll have to be symbols.

hash :hash,
  strip: false,
  keys: :symbol,
  values: :integer

I'm less sure now about supporting this. Should it only be allowed if strip is false? How should explicitly defined filters be handled?

hash :useless,
  keys: :symbol
hash :confusing,
  keys: :integer,
  values: :integer do
    boolean :what_am_i
  end

@tfausak tfausak closed this as completed Nov 14, 2013
@tfausak tfausak self-assigned this Apr 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant