Sha256: 5025251f2e1557d4e45d274f2f01822ae98d9a83e0d1bc094974809da4fce2ee
Contents?: true
Size: 599 Bytes
Versions: 1
Compression:
Stored size: 599 Bytes
Contents
module Databound class Utils def self.create_controller_unless_exists(path, resource) return if exists?(path) controller = Class.new(ApplicationController) controller.send(:include, Databound) controller.send(:define_method, :model) do resource.to_s.classify.constantize end Object.const_set(name(path), controller) end def self.exists?(path) begin name(path).constantize rescue NameError return false end true end def self.name(path) "#{path.camelize}Controller" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
databound-0.2.1 | lib/databound/utils.rb |