Comments (8)
I don't think we should do this. The benefit of doing this would be that all inputs must be specified. You couldn't create an interaction with one top-level hash that you pluck values out of arbitrarily. However, it would still be possible to do that with an array, since they can hold any number of anything.
from active_interaction.
I think we should revisit this one. If you want to loop over all the keys in a hash, you shouldn't have to worry about rogue values sneaking in:
class Interaction < ActiveInteraction::Base
hash :a
def execute
a.each { |k, v| puts "#{k} => #{v}" }
end
end
Interaction.run(a: { x: true })
# x => true
from active_interaction.
Maybe this should be an option.
from active_interaction.
I'm thinking the option should be called strict
and it should default to true. Here's how it would work:
class Interaction < ActiveInteraction::Base
hash :a, strict: false do
hash :x
end
def execute; a end
end
Interaction.run!(a: { x: { y: false }, z: true })
# => { x: {}, z: true }
from active_interaction.
👍
from active_interaction.
How should this behave with defaults?
class Interaction < ActiveInteraction::Base
hash :a, default: { x: true }
def execute; a end
end
Interaction.run!
# => {} or { x: true }?
from active_interaction.
I would think {x: true}
.
from active_interaction.
Fixed by #69.
from active_interaction.
Related Issues (20)
- Incorrect filtering of array of hashes in v5? HOT 1
- Activeinteraction::Inputs and ActiveRecord #build_where_clause HOT 1
- Bug: Cached default input values HOT 1
- Question: Would you like to add some hactoberfest labels? HOT 1
- Rails 7: ArgumentError (Could not find or build blob: expected attachable) HOT 1
- An `array` filter can mutate the state of the passed in Array instance
- array :emails is always nil. Why? HOT 2
- Missing some documentation on nested hash default options HOT 4
- `ActiveInteraction::Errors#merge!` does not merge custom options HOT 4
- Input access consistency issues HOT 2
- Something strange with full_messages method for errors HOT 2
- When use callback - compose work strange in interaction HOT 1
- Enum filter HOT 2
- Array Filter with default values aren't initialized on each run HOT 2
- Document typecasting to HashWithIndifferentAccess
- Nested forms HOT 3
- Two datatypes with same variable name HOT 2
- Mongoid::Criteria objects are resolved in object filter HOT 1
- Unexpected validation behavior on filters with validators
- Wrong error message when use hash of array of hashes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_interaction.