Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Reginald Braithwaite
RE: A different kind of sugar [ reply ]  
2008-04-30 13:42
There must be an easier way to do this, but perhaps this is a better way to go than belongs_to. I will work on it for the next release.

By: Matt Mower
A different kind of sugar [ reply ]  
2008-04-04 10:05
For some reason I find

class X
Ick::Let.belongs_to self
end

rather unappealing so I added this to sugar.rb:

module Ick
module Sugar
def self.const_missing( const )
sugar_module = Module.new
sugar_module.module_eval "
def self.included( base )
Ick.const_get( :#{const} ).belongs_to base
end
"
sugar_module
end
end
end

and now do:

class X
include Ick::Sugar::Let
end

which seems easier on my eye somehow. Of course it's probably grotesque somehow, I can't decide.