Sha256: 1117e9313dc5890a49236bc4682b4dd6ce0fb85a15796f2b641c37aed70dbd7e

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'versioncake'

module Refinery
  module Api
    class Engine < Rails::Engine
      include Refinery::Engine

      isolate_namespace Refinery::Api
      engine_name :refinery_api

      config.autoload_paths += %W( #{config.root}/lib )

      config.before_configuration do
        ::Rabl.configure do |config|
          config.include_json_root = false
          config.include_child_root = false

          # Motivation here it make it call as_json when rendering timestamps
          # and therefore display miliseconds. Otherwise it would fall to
          # JSON.dump which doesn't display the miliseconds
          config.json_engine = ActiveSupport::JSON
        end

        config.versioncake.supported_version_numbers = [1]
        config.versioncake.extraction_strategy = :http_header
      end

      config.after_initialize do
        Refinery.register_engine(Refinery::Api)
      end

      # initializer "refinery.api.environment", :before => :load_config_initializers do |app|
      #   # Refinery::Api::Config = Refinery::ApiConfiguration.new
      # end

      # def self.activate
      #   Dir.glob(File.join(File.dirname(__FILE__), "../../../app/**/*_decorator*.rb")) do |c|
      #     Rails.configuration.cache_classes ? require(c) : load(c)
      #   end
      # end
      # config.to_prepare &method(:activate).to_proc

      config.to_prepare do
        Decorators.register! ::Refinery::Api.root
      end

      # def self.root
      #   @root ||= Pathname.new(File.expand_path('../../../../', __FILE__))
      # end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-api-1.0.0.beta lib/refinery/api/engine.rb