mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
e567a5eb1a
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3356 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
25 lines
518 B
Ruby
25 lines
518 B
Ruby
module ActiveSupport
|
|
module JSON #:nodoc:
|
|
module Encoders
|
|
mattr_accessor :encoders
|
|
@@encoders = {}
|
|
|
|
class << self
|
|
def define_encoder(klass, &block)
|
|
encoders[klass] = block
|
|
end
|
|
|
|
def [](klass)
|
|
klass.ancestors.each do |k|
|
|
encoder = encoders[k]
|
|
return encoder if encoder
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Dir[File.dirname(__FILE__) + '/encoders/*.rb'].each do |file|
|
|
require file[0..-4]
|
|
end
|