Sha256: 72720a0becbc24538064cade41475a4e80af4db16dbf8fdd5f67757caba445d8
Contents?: true
Size: 739 Bytes
Versions: 2
Compression:
Stored size: 739 Bytes
Contents
module Sinatra SERIALIZERS_DEFAULT_PATH = './app/serializers' module JSON def initialize files_required super end def json(object, options={}) options = options.merge(settings.active_model_serializers) serializer = ActiveModel::Serializer.serializer_for(object, options) if serializer serializer.new(object, options).to_json else object.to_json(options) end end def files_required return unless settings.serializers_path Dir["#{ settings.serializers_path }/**/*.rb"].flatten.sort.each do |file| require file end end end Base.set :active_model_serializers, {} Base.set :serializers_path, SERIALIZERS_DEFAULT_PATH end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-active-model-serializers-0.0.3 | lib/sinatra-active-model-serializers/json.rb |
sinatra-active-model-serializers-0.0.2 | lib/sinatra_active_model_serializers/json.rb |