My favorite RSpec aliases

Development in compilers has advanced so much that static typed languages have reached the same level human-friendly level as dynamic languages and type safety is coming back while dynamic languages are fading away :) Lately I have been focusing more on safety when I develop code on dynamic languages, especially in Ruby. (I had a couple of days fun in Crystal and it feels like a minefield when working with Ruby again or any other dynamic language) »

Best service objects until now

Service objects was a big thing a couple years ago in Rails community, like everyone just learned about the single responsibility principle. In any case, personally I couldn’t find a Service Object pattern that I was happy with, neither from my brain nor from the Internetzz. Lately I have been using something that I can say it’s good enough. I call it PerformerService, meaning that it’s for service objects that should have a simple method, called perform. »

Creating methods dynamically in a Ruby object

It feels like Rails’ makes things hard when working with models that are not AR-related, which sees to be the case lately as we are integrating more and more external services. Sometimes you have a class, say User, that defines some methods like first_name, last_name etc. and you use an object of that class in forms in your Rails app. Now imagine that in a specific form you also need to render a couple more inputs, related to the user object BUT you don’t want to define those methods in your User class. »

With pattern in Ruby

I have been using lately this nitty gritty pattern mostly inspired by Ember’s with template helper. If you have an object (usually in your .erb template) which has a long diameter it becomes a bit problematic when you have to repeat it again and again.


Env variables inside Ember's index.html

Using environment variables in ember is straightforward: export your env vars using any tool like direnv and import them inside your config/environment.js using node’s process.ENV.YOUR_ENV_KEY.