Comments (4)
@sled using the alternative DSL a lot of these are already possible, will give more input tomorrow.
from porro.
thanks! the first one I already figured out how to do:
attribute :peak_months, Porro.set(Porro::Types::Enum.new(1..12))
2.3.0 :111 > a.peak_months = Set.new([55,1,66,12])
=> #<Set: {55, 1, 66, 12}>
2.3.0 :112 > a.peak_months
=> #<Set: {1, 12}>
However it still allows adding invalid values afterwards (due to the naked Set
returned):
2.3.0 :113 > a.peak_months << 55
=> #<Set: {1, 12, 55}>
2.3.0 :114 > a.peak_months
=> #<Set: {1, 12, 55}>
Would be cool if we could find an easy way around this (immutable? cloning? overloading?), otherwise we could rely on validations.
from porro.
Jup, was thinking about using a proxy or something, but as there is an unlimited number of methods which modify a Set/Array/Enumerable I decided if's not worth the trouble. Yes, we should handle this using validations, makes more sense.
Isn't there a Default.new wrapper class already?
from porro.
and yes I agree we should probably provide an empty list by default, care to take a PR?
from porro.
Related Issues (1)
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 porro.