<inf03>
dile al gilipollas que tienes a la derecha que se calle
inf04 has joined #amber
<inf05>
alex
<inf05>
polla gorda
<inf04>
quie lo que
inf03 has left #amber [#amber]
inf05 has left #amber [#amber]
<inf04>
eeee
<inf04>
kk
<inf04>
ñ
<inf04>
ñ
<inf04>
pp
<inf04>
p
inf04 has quit [Quit: Leaving]
<FromGitter>
<nsuchy> @damianham Thanks for the regex example. I ended up doing authorization on my own and keeping the built-in authentication for identity-purposes only while checking things like the is_admin attribute of the current user on my own.
<FromGitter>
<nsuchy> Any thoughts on the implementation details?
<FromGitter>
<nsuchy> would it be more appropriate to return some sort of exception from the generator, or should I just check if the model name is a keyword, stop the initialization and return some text to the console
<FromGitter>
<Blacksmoke16> `["type"].includes("Type")` would be false
<FromGitter>
<nsuchy> I added a .downcase
<FromGitter>
<nsuchy> just now
<FromGitter>
<Blacksmoke16> cool
<FromGitter>
<nsuchy> Unfortunately we can't make keywords a constant unless it's declared higher up I believe
<FromGitter>
<Blacksmoke16> sure you can
<FromGitter>
<nsuchy> That leads to a larger question, does Crystal have functionality to determine if a word is a reserved/keyword
<FromGitter>
<nsuchy> where would we declare it?
<FromGitter>
<nsuchy> Because I get a compiler error
<FromGitter>
<Blacksmoke16> outside of `initialize`
<FromGitter>
<Blacksmoke16> like where all the properties are declared
<FromGitter>
<Blacksmoke16> also dont really need the `of String` is inferred from the contents of the array
<FromGitter>
<nsuchy> I can remove the of String if you'd like, that's just to be clear that we're checking as a string
<FromGitter>
<Blacksmoke16> might be worth throwing a `# :nodoc:` on the const as well?
<FromGitter>
<Blacksmoke16> > that's just to be clear that we're checking as a string ⏎ ⏎ What happens if you did like `def initialize(name : String, fields)`
<FromGitter>
<nsuchy> I’ll try that shortly
<FromGitter>
<nsuchy> Stepped away from keyboard
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<nsuchy> I can type annotate the name though instead
<FromGitter>
<nsuchy> Or we could leave out entirely as it works without
<FromGitter>
<Blacksmoke16> imo more type restrictions the better, unless you actually want any type
<FromGitter>
<nsuchy> We need a string now
<FromGitter>
<nsuchy> Because of the keyword checking
<FromGitter>
<nsuchy> So adding a string type restriction seems good to me
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<Blacksmoke16> and just an fyi if you didn't know this. the main point of moving the array to a constant is to prevent it from having to allocate memory for the array every time you new up a Scaffold class
<FromGitter>
<Blacksmoke16> as its a constant so only has to be done once. The other option would be to use a tuple instead of an array, i.e. just replace the `[]` with `{}`, tuples are allocated on the stack so are much lighter perf wise, like 10x faster
<FromGitter>
<Blacksmoke16> just something to keep in mind
<FromGitter>
<Blacksmoke16> afk a while, driving home
<FromGitter>
<nsuchy> No worries. Taking a break anyways. Do tuples have a `.includes?` method too? If so switching is a no brainer. I want my first PR to be as good as possible so every critique is appreciated 🙃
<FromGitter>
<nsuchy> Also looking at the issue from a larger perspective should we also perform the same checks on other generators. Could we move keywords up higher and check the same constant on multiple generators? For example the controller and model generators.
<FromGitter>
<nsuchy> So we have access to `.includes?`
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<Blacksmoke16> array and tuple both include indexable which include enumerable which gives you includes?
<FromGitter>
<Blacksmoke16> probably could yes, could prob declare a module like `module Crystal` and define your constant in there, then reference it via `Crystal::Keywords`
<FromGitter>
<Blacksmoke16> prob would be similar to what the stdlib would do as well if they ever include a list in the code
<FromGitter>
<nsuchy> I want to go to each generator command and check a central list. Here’s a better question. If we’re doing these checks on multiple generators, which file should `Crystal::Keywords` be defined in?
<FromGitter>
<Blacksmoke16> good question
<FromGitter>
<nsuchy> A turtle sounds great for our needs
<FromGitter>
<nsuchy> Tuple 😂
<FromGitter>
<Blacksmoke16> well if its a constant it doesnt really matter much either way
<FromGitter>
<nsuchy> Hmm okay
<FromGitter>
<nsuchy> As for where to declare the keywords constant...
<FromGitter>
<Blacksmoke16> i dont know the file structure enough to have a guess