Metaprogramming in ruby – DEV Community

The ruby programming language is thought for 2 main info: One is its core philosophy with object-oriented programming the place “Every little thing is an object”, the opposite vital one is its unimaginable flexibility to outline DSLs and “magic” courses. This magic is on function and a fairly particular function of ruby referred to as […]

Fun with classes and constants

Ruby is considerably versatile at occasions. Suppose you wish to outline a category dynamically, and I do…. class Factor; finish Okay, that’s not dynamic # nonetheless not dynamic however getting there. def define_a_class Factor = finish # okay then I see def define_a_class(title) Object.const_set(title, finish define_a_class(‘Factor’) => Factor That is nice however what […]

Write your own Domain Specific Language in Ruby

Let’s do some metaprogramming in Ruby! This text assumes you’ve some familiarity with writing Ruby and are desirous about studying methods to use metaprogramming. This text can also be obtainable as a video recording of a talk. What’s a DSL? Let’s begin with some definitions on what we’ll be . The abbreviation DSL stands for […]