Root of Evil

Talking about ruby and other stuff.

Callbacks Extraction

| Comments

The unbridled use of the go to statement has an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress.

Rails provide powerful callback technique and as a powerful tool it could injure in newbie hands.

Refactoring Wrappers

| Comments

Introduction

Very often in my everyday practice I faced a task when you need to create a communication between your own services or some 3rd party service that don’t have a implementation yet. So what is the best way to doing that?

Wrapper - it is a piece of code that will be responsible for communication between your application and external service.

All About Duck Types

| Comments

Introduction

I heard a lot about Duck Types in Rails but I have never saw how can I used in a real-time application. Today I will show you how to use duck types in examples.

Duck Typing is a style of dynamic typing in which an object’s methods and properties determine the valid semantics, rather than its inheritance from a particular class or implementation of a specific interface.

Monads the Heart of the Matter

| Comments

Introduction

Monads came form functional programming like Haskell. And this is not a secret from no-one that Ruby takes some parts from this languages. So, what is Monad about?

Monad is a structure that represents computations. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad. Today we will create monad and see how it will help us.

Don’t Use STI in Your Rails Apps

| Comments

Single table inheritance is a way to emulate object-oriented inheritance in a
relational database. When mapping from a database table to an object in an
object-oriented language, a field in the database identifies what class in the hierarchy the object belongs to

Single Table Inheritance(STI) is a useful and sharp technique, and like any other high level instrument you should use it in an appropriate place. Let’s take a closer look with examples