
dm-is-remixable fails with namespaced models
Reported by Nick | December 17th, 2010 @ 06:22 AM
(also initially reported on github - https://github.com/datamapper/dm-is-remixable/issues/issue/9 - whoops)
Here's a simple testcase:
require 'rubygems'
require 'dm-core'
# see ticket [#1458](/projects/20609/tickets/1458 "Ticket #1458") - using activesupport doesnt' fix the problem
require 'extlib/inflection'
module ActiveSupport
Inflector = ::Extlib::Inflection
end
require 'dm-is-remixable'
module Test
module Foo
include DataMapper::Resource
is :remixable
property :id, Serial
end
class WorkingFoo
include DataMapper::Resource
property :id, Serial
property :bar_id, Integer
end
class Bar
include DataMapper::Resource
property :id, Serial
has n, :working_foos # Works
remix n, :foos # Doesn't work
end
end
I get:
NameError: uninitialized constant Foo
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:13:in `full_const_get'
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:in `each'
from dm-core-1.0.2/lib/dm-core/core_ext/object.rb:10:in `full_const_get'
from dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:160:in `remix'
It might actually be a bug in dm-core, I guess (since we're using full_const_get) - but the has n, :working_foos doesn't raise in the same manner.
Playing around with passing various other options to remix...
remix n, ::Test::Foo
remix n, "::Test::Foo"
SyntaxError: dm-core-1.0.2/lib/dm-core/model/relationship.rb:343: syntax error, unexpected tDIVIDE
def test/bar_foos(query = nil)
^
from dm-core-1.0.2/lib/dm-core/model/relationship.rb:337:in `class_eval'
from dm-core-1.0.2/lib/dm-core/model/relationship.rb:337:in `create_relationship_reader'
from dm-core-1.0.2/lib/dm-core/model/relationship.rb:133:in `has'
from dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:311:in `remix_one_to_many'
from dm-is-remixable-1.0.2/lib/dm-is-remixable/is/remixable.rb:220:in `remix'
Comments and changes to this ticket
-
Nick December 17th, 2010 @ 08:48 AM
Seems some work has already been done on this between 1.0.2 and trunk - but there is another failure case still in trunk.
https://github.com/datamapper/dm-is-remixable/pull/10 is necessary for namespaced models to be usable for me.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »