eliminate "superclass mismatch for class Resource" error

Previously libraries/pacemaker/mixins/resource_meta.rb had:

  module Pacemaker
    class Resource
      module Meta
        ...

but libraries/pacemaker/resource.rb had:

  module Pacemaker
    class Resource < Pacemaker::CIBObject
      ...

This would work fine if libraries/pacemaker/resource.rb was loaded
before libraries/pacemaker/mixins/resource_meta.rb, because then
Pacemaker::Resource would have Pacemaker::CIBObject as its parent class,
and the mixin would simply add the Meta module within the existing
Pacemaker::Resource class.  However, due to Chef's somewhat erratic
method of loading libraries, sometimes it could happen the other way
around, in which case Pacemaker::Resource would be initially defined by
the mixin with no parent class, and then when resource.rb was loaded, it
would attempt to redefine Resource to have a parent class, triggering
the error.
This commit is contained in:
Adam Spiers
2014-03-13 20:38:35 +00:00
parent 50d7571556
commit 2036cbc223
3 changed files with 20 additions and 18 deletions

View File

@@ -2,7 +2,8 @@
# (priority, target-role, is-managed)
module Pacemaker
class Resource
module Mixins
module Resource
module Meta
def self.included(base)
base.extend ClassMethods
@@ -25,4 +26,5 @@ module Pacemaker
end
end
end
end
end

View File

@@ -5,7 +5,7 @@ class Pacemaker::Resource::Group < Pacemaker::Resource
TYPE = 'group'
register_type TYPE
include Pacemaker::Resource::Meta
include Pacemaker::Mixins::Resource::Meta
attr_accessor :members

View File

@@ -6,7 +6,7 @@ class Pacemaker::Resource::Primitive < Pacemaker::Resource
TYPE = 'primitive'
register_type TYPE
include Pacemaker::Resource::Meta
include Pacemaker::Mixins::Resource::Meta
attr_accessor :agent, :params, :op