Check method exists for plugin

I’m writing a plugin that requires that an implementing Model has a
method called ‘title’ defined.

For my init.rb, I have:

require 'article_assignable'
ActiveRecord::Base.send(:include, David::ArticleAssignable)

Then in article_assignable.rb:

module David
  module ArticleAssignable
    def self.included(base)
      base.extend Plugin
    end

    module Plugin
      def article_assignable
        # Set-up polymorphic association
        has_many :assignables, :as => :object



        # Raise exception if the model doesn't have a Title

attribute.
# Do this by checking for the title method.
raise “Requires Title method in #{self.class}” unless
respond_to?(:title)
end
end

  end
end

The problem I’m getting is using respond_to?. It seems to be checking
Class rather than the Active Record model I have using:

class Film < ActiveRecord::Base
  article_assignable
end

Any help would be much appreciated.

Try posting your question on refwell.com. You might get your answer
there
James

On Feb 5, 7:36 pm, David W. [email protected]