faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<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> if this is true, do we want to redefine the `struct` in every Class? https://github.com/Blacksmoke16/granite/blob/annotation-columns/src/granite/columns.cr#L7
<FromGitter> <drujensen> maybe we need to because of the `T.class`?
<FromGitter> <Blacksmoke16> no no im using like
<FromGitter> <Blacksmoke16> ``` include Columns ⏎ extend Columns::Class``` [https://gitter.im/amberframework/amber?at=5c08a98511bb5b25046e1486]
<FromGitter> <Blacksmoke16> within `Granite::Base`
<FromGitter> <Blacksmoke16> @drujensen
<FromGitter> <drujensen> oooh! I was very confused by the use of `Class`
<FromGitter> <drujensen> I didn’t think you could do that
<FromGitter> <Blacksmoke16> yea i should prob rename it like `ClassMethods`
<FromGitter> <drujensen> isn’t that a reserved word?
<FromGitter> <drujensen> right
<FromGitter> <drujensen> ok
<FromGitter> <Blacksmoke16> not in this case since its inside the `Granite::Columns` module it inherits that name
<FromGitter> <Blacksmoke16> so would be like `Granite::Columns::Class` which wouldnt conflict
<FromGitter> <drujensen> right, ok
<FromGitter> <drujensen> just didn’t think it would compile
<FromGitter> <drujensen> crystal parser didn’t complain
<FromGitter> <Blacksmoke16> i renamed it `ClassMethods` just to be more clear
<FromGitter> <drujensen> ok, maybe you can do: ⏎ ⏎ ```macro inherited ⏎ extend ClassMethods ⏎ end``` [https://gitter.im/amberframework/amber?at=5c08aad180986419d5482925]
<FromGitter> <Blacksmoke16> why?
<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> <Blacksmoke16> like what is happening on master for transactions https://github.com/amberframework/granite/blob/master/src/granite/transactions.cr#L4
<FromGitter> <Blacksmoke16> where in base file we include transactions and extend transactions::classMethods
snsei has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> well all query specs are passing now
<FromGitter> <drujensen> This is a fairly common design pattern in Ruby. Just thinking we could do something similar: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c08b27426de6f08228da1e4]
<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> <drujensen> yeah
<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> holy shit
<FromGitter> <Blacksmoke16> game changer
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5pi9
<FromGitter> <drujensen> nice
<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]
feepbot has quit [Ping timeout: 250 seconds]
feepbot has joined #amber
hexreel has joined #amber
<FromGitter> <robacarp> ❤️
<FromGitter> <robacarp> @Blacksmoke16 some chatter about the future of annotations in this thread: https://github.com/crystal-lang/crystal/issues/7149#issuecomment-444839270
<FromGitter> <Blacksmoke16> yea i saw 😬
<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]
snsei has joined #amber
snsei has quit [Ping timeout: 252 seconds]
snsei has joined #amber
snsei has quit [Ping timeout: 268 seconds]
<FromGitter> <waghanza> hi @/here, I'll soon (when `crystal` `0.27.1` will be out) compare `crystal` among other in real condition ⏎ @see https://github.com/the-benchmarker/web-frameworks/pull/632#issuecomment-445024651 ⏎ I have different results than *tfb*, and honestly I do not know why
<FromGitter> <drujensen> hi @waghanza what kinda diff?
<FromGitter> <drujensen> oh, right. i recall now.
<FromGitter> <drujensen> I tried fixing this but seems like something else is a bottleneck