- ARCHIVE / Ruby
- Inheritance, revisited
Late last year, I wrote a piece titled “Where’s my inheritance“, in which I argued against the inheritance implementation of various JavaScript libraries. I’ve recently been working on a rewrite of JS.Class that is much more Ruby-like, and it’s caused me to re-examine my thoughts on this issue.
With JS.Class 1.x, I made the conscious decision [...] - Another super-tiny Rails plugin: classy_inputs
Good lord do I ever hate input tags. (YUI hates them too, but I’ll leave that story for another time). All the different types should really have been different tag names, and they are a total pain to use with CSS. As such, I used to end up doing tedious stuff like adding a :class [...]
- Tiny Sunday coding project: has_password
Just a little announcement about something I cooked up this afternoon. It’s nothing ground-breaking but might save you a little time. Basically, I was getting super-tired of writing the same authentication code for every project so I extracted it into a plugin called has_password. Install like so:
ruby script/plugin install git://github.com/jcoglan/has_password
Now, this plugin is tiny and [...] - JS.Class 1.6.0: Forwardable, State, and Ruby
A little update: JS.Class 1.6.0 is now out. The main new features are a port of Ruby’s Forwardable module for method delegation, an implementation of the State pattern (which I’m using heavily for building UI code), and JS.Ruby, which is something I wrote about a few weeks back. Also, I’ve implemented the extended hook to [...]
- Quick and dirty icons in ActionView
Tiny tiny Rails tip: you can use method_missing to make using icon sets easier when writing Rails views. Behold:
module ApplicationHelperdef method_missing(sym, *args)
super unless sym.to_s =~ /_icon$/
image_tag(”silk/#{sym.to_s.gsub(/_icon$/, ”)}.png”)
endend
Now the following call:
<%= pencil_icon %>
produces this image tag:
<img src=”/images/silk/pencil.png” /> - On-demand thumbnails with Rails and rmagick
My, it’s been a while since I wrote a Rails tutorial. I’m going to come back from the land of esoteric JavaScript techniques for a minute and talk about something you might actually want to use in real life.
Many people, when writing an app that uses image uploads in some way, like to generate thumbnails [...] - With a little help from with
You know the old saying:
with (JavaScript) {
metaprogramming.is(’possible’);
}
I’m going to leave the discussion of what constitutes metaprogramming to another day (read: never), but what I will say is that I’m becoming more interested in DSLs and fluent interfaces. I want the code I write to work at a very high level, where [...] - Let’s get committed
Right, I know I said I’d do this a long time ago, but I just got round to checking up on some of my Rails patches with the hopes of persuading one or two of you that they might be worth supporting and getting committed to the core. This post concerns a couple of patches [...]
- Deriving the Y combinator
Before I start in on this: be aware I’m mostly writing this to force myself to understand something by writing it down. If you get anything out of it, consider it a bonus. I will be deriving Y() in JavaScrpit, and giving a version in Ruby.
After stumbling on this article on Raganwald last year (thoroughly [...] - Announcing Holly
After some discussion at work about how to manage JavaScript dependencies in our CMS, I decided to write a quick Rails plugin for doing just that. It’s called Holly, and it lets you use special comments inside script and CSS files to declare their dependencies. Whenever you use javascript_include_tag or stylesheet_link_tag, Holly inspects the dependencies [...]