Cutting Corners or Why Rails May Kill Ruby
1–5 of 5 posts
Re: Cutting Corners or Why Rails May Kill Ruby
#2I recently learned that `forty_two` [0] is monkeypatched into Array of all places by Rails. More or less entirely as a meta joke.
Re: Cutting Corners or Why Rails May Kill Ruby
#3While I agree with the sentiment, I don't believe it's necessarily cutting corners. Rather, it's by design. Rails values "elegance," and leans towards monolithism. Monkey patching is the means to those ends.
So even though I agree with you, I think it's going to be very difficult changing the philosophy of the Rails' ecosystem.
Re: Cutting Corners or Why Rails May Kill Ruby
#4What if you could require() your patch just where you needed it? You'd have the utility and elegance of the simple solution, without abusing the global namespace.
That's exactly what you'd do in Scala.
implicit class HtmlHelpers(node: Node) {
def id: String = node \ "@id" text
def name: String = node \ "@name" text
def cssClass: String = node \ "@class" text
def href: String = node \ "@href" text
}
And I haven't abused anything. Whenever I need it, even within another method, I can just import until.HtmlHelpers.Re: Cutting Corners or Why Rails May Kill Ruby
#5What if you could require() your patch just where you needed it? You'd have the utility and elegance of the simple solution, without abusing the global namespace. That's exactly what you'd do in Scala. implicit class HtmlHelpers(node: Node) { def id: String = node \ "@id" text def name: String = node \ "@name" text def cssClass: String = node \ "@class" text def href: String = node \ "@href" text } And I haven't abus…
refines are coming soon into ruby-core (2.2.0 IIRC).