On Mar 21, 12:32 pm, funny_falcon <[email protected]> wrote:
> > because I cannot define classes inside of a method
> why?
<snip>

That would work!  :-)  But I would have to subvert a Ruby idiom,
instead of just subverting an ORM framework preference.

I suppose I should have been more specific:

I cannot define classes that are available to namespaces outside of
the method, unless I refer to those classes using a variable name
throughout the code, instead of a constant as normal.

dynamic constant assignment    Test = Class.new(Sequel::Model(:test))
(SyntaxError)

I would have to do:

module Test
  class << self
    attr_accessor :model
  end
end

class TestSetup
  def up
    Test.model = Class.new(Sequel::Model(:test))
  end
end

And then reference the class otherwise known as "Test" as "Test.model"
throughout the codebase.  This works, but I feel that it fails the
"least surprise" qualifier.

I also realize that constants can indeed be re-assigned in Ruby, using
some meta-programming techniques and some warning-stifling, but I'm
really not willing to go there for some simple Sequel Model demos.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to