<FromGitter>
<Blacksmoke16> got default value working now
<FromGitter>
<Blacksmoke16> had to add a new `quote_value` method, to define how value of type T get quoted
<FromGitter>
<Blacksmoke16> bool/number dont, string/arrays do
<FromGitter>
<Blacksmoke16> but in diff ways
robacarp has quit [Ping timeout: 272 seconds]
robacarp has joined #amber
snsei has joined #amber
<FromGitter>
<drujensen> @Blacksmoke16 just to confirm, if you `include Granite::Columns` then the `module Class` will extend the class with `primary_key` and `columns`? I can’t find anything in the crystal docs that discusses this. It’s pretty slick. kinda like the Ruby `included` hook (primarily used to extend class methods).
<FromGitter>
<drujensen> I may have known this and just having a senior moment
<FromGitter>
<drujensen> kinda like ruby’s included callback
<FromGitter>
<drujensen> sorry, macro included
<FromGitter>
<drujensen> grh
<FromGitter>
<drujensen> can’t type
<FromGitter>
<drujensen> If its in this file, I know what the heck is going on
<FromGitter>
<Blacksmoke16> nothing really fancy going on, just using it as a separate namespace so some methods get includes on instance level and others on class level
<FromGitter>
<drujensen> then you just `include Logging` and it will both include the instance methods and extend the class methods.
<FromGitter>
<Blacksmoke16> ah right
<FromGitter>
<Blacksmoke16> could do, i dont have a strong opinion either way
<FromGitter>
<drujensen> I was just very confused by the `module Class` and how it would work. :-D
<FromGitter>
<Blacksmoke16> ;)
<FromGitter>
<drujensen> Anyway, I think this stuff is very clean and looking forward to seeing it work
<FromGitter>
<drujensen> I’ve been thinking about Amber Controller methods and using annotations to define the `routes` and `link_to` helpers.
<FromGitter>
<Blacksmoke16> is a thing in symfony that i think is pretty cool but not should how it could be implemented atm, since i dont think you can add annotations to methods?
<FromGitter>
<drujensen> Possibly replace the config/routes.cr
<FromGitter>
<Blacksmoke16> and is one more that defines a group on the route, so if you're using serialization groups it would know to use that group on serialize
<FromGitter>
<Blacksmoke16> but for that would have to be able to define annotations on methods, which you cant atm afaik
<FromGitter>
<Blacksmoke16> holy shit maybe you can, sec
<FromGitter>
<drujensen> Is annotations in the docs yet?
<FromGitter>
<Blacksmoke16> but would need a way to figure out like `what method am i in` vs looping thru them all...
<FromGitter>
<Blacksmoke16> not really afaik?
<FromGitter>
<Blacksmoke16> not much to them tbh
<FromGitter>
<drujensen> It seems like it might be doable. Just to add routes anyway
<FromGitter>
<drujensen> find all `@[Route]` and add the path pointing to the Class.method
<FromGitter>
<Blacksmoke16> that would be doable yea
<FromGitter>
<Blacksmoke16> but doing route specific things like `get the annotation for current method im in` im not sure you an do atm
<FromGitter>
<drujensen> not sure that would be needed
<FromGitter>
<Blacksmoke16> maybe not, if you use it like you're thinking
<FromGitter>
<Blacksmoke16> where just use it to populate a config obj/hash or something
<FromGitter>
<drujensen> we could have a class level Resource annotation
<FromGitter>
<drujensen> right
<FromGitter>
<Blacksmoke16> where when a route gets hit, it fetches its "config obj" that was built out from annotations, which stores what permission it would have, or how it should be serialized etc
<FromGitter>
<Blacksmoke16> that'd be pretty slick
<FromGitter>
<drujensen> then we could generate helpers for `link_to`
<FromGitter>
<drujensen> Permissions would be another thing, but yeah, you could do that too
<FromGitter>
<drujensen> but then we have annotation hell. lol
<FromGitter>
<Blacksmoke16> :P
<FromGitter>
<drujensen> see how easy it is to get out of control? lol
<FromGitter>
<Blacksmoke16> indeed haha
<FromGitter>
<Blacksmoke16> but yea, im quite happy how this is coming along
<FromGitter>
<drujensen> yea, its looking pretty clean. I gotta go. ttyl.
<FromGitter>
<Blacksmoke16> o/
<FromGitter>
<damianham> @drujensen I am not so sure replacing config/routes.cr with annotations would be a desirable change and you allude to the possibility of annotation hell. Route annotations would be a useful addition but replacement would not be a good idea. You would effectively be replacing 1 line that establishes RESTful resources in the routes config with 6 lines of annotations in the controller. If you want to localise the
<FromGitter>
... route config to the controller (which is a good thing) the quick and easy way to do this (with no changes required to Amber) is to separate your application into modules, each with a local routes file (that is what I do). Yup - banging the modularisation drum again :)
snsei has joined #amber
snsei has quit [Remote host closed the connection]
<robacarp>
I like hearing from asterite that he thinks it's half baked. There's a lot of potential there, but I hope it gets some iteration before it solidifies
<FromGitter>
<Blacksmoke16> indeed, is always room for improvement
<FromGitter>
<Blacksmoke16> but id imagine it wont be soon those iterations would happen
<robacarp>
always more things to do
<FromGitter>
<Blacksmoke16> yea no kidding, currently trying to figure out best way to implement custom types, using UUID as a test
<FromGitter>
<Blacksmoke16> but im thinking the implementation is going to be diff for each db adapter
snsei has joined #amber
<robacarp>
if nothing else, doing the legwork of each adapter individually will reveal any similarities
<FromGitter>
<Blacksmoke16> aye, working on pg for now
<FromGitter>
<Blacksmoke16> gotta remember how this works :p
snsei has quit [Remote host closed the connection]
snsei has joined #amber
<FromGitter>
<Blacksmoke16> idea i had was like instead of `require granite/adapters/pg` do `require granite/adapters/pg/*` and just include adapter specific stuff in each adapter directory
snsei has quit [Remote host closed the connection]
<FromGitter>
<drujensen> @damianham thanks for your feedback. You could annotation the class as a restful resource instead of each method, so I think that addresses your first concern. The other benefit is that you can verify the routes are valid at compile time. We can create helper methods i.e. `users_path` to be used in the `link_to` that is a validated path. I personally am not a fan of annotations and think the code is ugly but I
<FromGitter>
... can see some of the benefits for using them.
<FromGitter>
<drujensen> What you are calling `modular` is more of a file structure preference. We might want to come up with a better name because `modular` is more commonly used as a design pattern for addressing coupling issues.
snsei has joined #amber
snsei has quit [Remote host closed the connection]