Code Monkey home page Code Monkey logo

Comments (4)

lwe avatar lwe commented on August 28, 2024

@sled using the alternative DSL a lot of these are already possible, will give more input tomorrow.

from porro.

sled avatar sled commented on August 28, 2024

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.

lwe avatar lwe commented on August 28, 2024

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.

lwe avatar lwe commented on August 28, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.