Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

extend_terminology, refs, and inheritance #40

Open
mbklein opened this issue Jul 19, 2013 · 2 comments
Open

extend_terminology, refs, and inheritance #40

mbklein opened this issue Jul 19, 2013 · 2 comments

Comments

@mbklein
Copy link
Contributor

mbklein commented Jul 19, 2013

This looks like a bug to me, but I don't know enough about how inheritance is implemented to understand it fully. I have a workaround for now, but it should be better understood, documented, and maybe fixed if it's actually a problem.

class Foo
  include OM::XML::Document
  set_terminology do |t|
    t.root(:path=>"foo") 
    t.bar
    t.barbaz(:ref=>[:bar], :attributes=>{:type=>"baz"})
  end
end
Foo.terminology.xpath_for :bar          # should be //bar
Foo.terminology.xpath_for :barbaz       # should be //bar[@type="baz"]

class FooBar < Foo
  extend_terminology do |t|
    t.barquux(:ref=>[:bar], :attributes=>{:type=>"quux"})
  end
end
FooBar.terminology.xpath_for :bar       # should be //bar
FooBar.terminology.xpath_for :barbaz    # should be //bar[@type="baz"]
FooBar.terminology.xpath_for :barquux   # should be //bar[@type="quux"]

class FooBaz < Foo
  extend_terminology do |t|
    t.baz
    t.bazquux(:ref=>[:baz], :attributes=>{:type=>"quux"})
  end
end
FooBaz.terminology.xpath_for :bar       # should be //bar
FooBaz.terminology.xpath_for :barbaz    # should be //bar[@type="baz"]
FooBaz.terminology.xpath_for :baz       # should be //baz
FooBaz.terminology.xpath_for :bazquux   # should be //baz[@type="quux"]

# Workaround: Define FooBar and FooBaz again, but with
  include OM::XML::Document
  use_terminology(Foo)
# before the extend_terminology block
@jcoyne
Copy link
Contributor

jcoyne commented Jul 19, 2013

What is the actual behavior you are seeing and how does it differ from the expected behavior?

@mbklein
Copy link
Contributor Author

mbklein commented Jul 19, 2013

Expected behavior: FooBar and FooBaz have full access to Foo's terminology, and can extend it, since they inherit from the class directly.

Observed behavior: FooBar and FooBaz have no knowledge of Foo's terms, but can define their own, even without including OM::XML::Document explicitly. However, they cannot refer to anything in Foo's terminology in their definitions.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants