Skip to content
Experimental constantizing
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
LICENSE
README.md
Rakefile
constantine.gemspec

README.md

Constantine

module Support
  class Ticket
  end
end

> Constantine.constantize("SupportTicket")
=> Support::Ticket 

Caveat Emptor!

A railtie exists for patching ActiveSupport's implementation:

"SupportTicket".constantize

The idea was to allow more implicit definitions in a Rails app with a lot of namespace modules:

has_many :support_tickets

instead of

has_many :support_tickets, :class_name => "Support::Ticket"

It seems to break too much auto-loading to be useful, so I honestly can't actually recommend using this for anything right now. It's just an experiment.

Copyright

Copyright (c) 2011 Jason L Perry. See LICENSE for details.

Something went wrong with that request. Please try again.