Building rubymine support into metaprogramming plugin


I have a plugin, built for a customer, which uses the method missing and association reflections on has_one and belongs_to to build an "automatic demeter" referencing as an extension for activerecord objects. This gives a form of delegation but without this explicity being declared.

For example, if there is a request object defined as such

class Request << ActiveRecord::Base
  has_one :product

and a product

class Product << ActiveRecord::Base
  def price

when you have an instance of request{:product=>})


request.product_price will return 10

and for

request.product_price will return nil.

The main reason for this plugin was to form an easy migration from long chained and error prone code that I inheritied (Rails 2.1.1 and Ruby 1.8.6), which means in most cases I can just replace the request.product.price with request.product_price or object.request_product_price (if called from another association 'object').

Long preamble over. Now for the question.

Since I control the code for this plugin, is there anyway to register it in such a way that it will allow rubymine to resolve the references? The metaprogramming is mainly a method_missing injected into ActiveRecord::Base, but currenly always highlights as a reference which can't be resolved to any valid target.

1 comment
Comment actions Permalink

I'm in the same position.  We're developing an internal API that is ripe for a metaprogrammed DSL but the target audience varies in programming ability and they've become very productive using autocomplete.

It would be well worth the investment for us to learn how to create a small autocomplete system in RubyMine like the one for rails.



Please sign in to leave a comment.