Extracted new_subclass_instance method to a module.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8183 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
eb15c9eaad
commit
805c65f55d
2 files changed
+44
-16
No files matched your search
@@ -16,6 +16,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class CustomField < ActiveRecord::Base
|
||||
include Redmine::SubclassFactory
|
||||
|
||||
has_many :custom_values, :dependent => :delete_all
|
||||
acts_as_list :scope => 'type = \'#{self.class}\''
|
||||
serialize :possible_values
|
||||
@@ -155,22 +157,6 @@ class CustomField < ActiveRecord::Base
|
||||
find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
|
||||
end
|
||||
|
||||
# Returns an instance of the given subclass name
|
||||
def self.new_subclass_instance(class_name, *args)
|
||||
klass = nil
|
||||
begin
|
||||
klass = class_name.to_s.classify.constantize
|
||||
rescue
|
||||
# invalid class name
|
||||
end
|
||||
unless subclasses.include? klass
|
||||
klass = nil
|
||||
end
|
||||
if klass
|
||||
klass.new(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def type_name
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user