lib/grape.rb in grape-0.11.0 vs lib/grape.rb in grape-0.12.0

- old
+ new

@@ -18,115 +18,145 @@ require 'active_support/ordered_hash' require 'active_support/core_ext/object/conversions' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/hash/deep_merge' +require 'active_support/dependencies/autoload' require 'grape/util/content_types' require 'multi_json' require 'multi_xml' require 'virtus' require 'i18n' require 'thread' I18n.load_path << File.expand_path('../grape/locale/en.yml', __FILE__) module Grape - autoload :API, 'grape/api' - autoload :Endpoint, 'grape/endpoint' + extend ActiveSupport::Autoload - autoload :Route, 'grape/route' - autoload :Namespace, 'grape/namespace' + eager_autoload do + autoload :API + autoload :Endpoint - autoload :Path, 'grape/path' + autoload :Route + autoload :Namespace - autoload :Cookies, 'grape/cookies' - autoload :Validations, 'grape/validations' - autoload :Request, 'grape/http/request' + autoload :Path + autoload :Cookies + autoload :Validations + autoload :Request, 'grape/http/request' + end + + module Http + extend ActiveSupport::Autoload + eager_autoload do + autoload :Headers + end + end + module Exceptions - autoload :Base, 'grape/exceptions/base' - autoload :Validation, 'grape/exceptions/validation' - autoload :ValidationErrors, 'grape/exceptions/validation_errors' - autoload :MissingVendorOption, 'grape/exceptions/missing_vendor_option' - autoload :MissingMimeType, 'grape/exceptions/missing_mime_type' - autoload :MissingOption, 'grape/exceptions/missing_option' - autoload :InvalidFormatter, 'grape/exceptions/invalid_formatter' - autoload :InvalidVersionerOption, 'grape/exceptions/invalid_versioner_option' - autoload :UnknownValidator, 'grape/exceptions/unknown_validator' - autoload :UnknownOptions, 'grape/exceptions/unknown_options' - autoload :InvalidWithOptionForRepresent, 'grape/exceptions/invalid_with_option_for_represent' - autoload :IncompatibleOptionValues, 'grape/exceptions/incompatible_option_values' + extend ActiveSupport::Autoload + autoload :Base + autoload :Validation + autoload :ValidationErrors + autoload :MissingVendorOption + autoload :MissingMimeType + autoload :MissingOption + autoload :InvalidFormatter + autoload :InvalidVersionerOption + autoload :UnknownValidator + autoload :UnknownOptions + autoload :InvalidWithOptionForRepresent + autoload :IncompatibleOptionValues autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type' autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type' - autoload :InvalidMessageBody, 'grape/exceptions/invalid_message_body' - autoload :InvalidAcceptHeader, 'grape/exceptions/invalid_accept_header' + autoload :InvalidMessageBody + autoload :InvalidAcceptHeader end module ErrorFormatter - autoload :Base, 'grape/error_formatter/base' - autoload :Json, 'grape/error_formatter/json' - autoload :Txt, 'grape/error_formatter/txt' - autoload :Xml, 'grape/error_formatter/xml' + extend ActiveSupport::Autoload + autoload :Base + autoload :Json + autoload :Txt + autoload :Xml end module Formatter - autoload :Base, 'grape/formatter/base' - autoload :Json, 'grape/formatter/json' - autoload :SerializableHash, 'grape/formatter/serializable_hash' - autoload :Txt, 'grape/formatter/txt' - autoload :Xml, 'grape/formatter/xml' + extend ActiveSupport::Autoload + autoload :Base + autoload :Json + autoload :SerializableHash + autoload :Txt + autoload :Xml end module Parser - autoload :Base, 'grape/parser/base' - autoload :Json, 'grape/parser/json' - autoload :Xml, 'grape/parser/xml' + extend ActiveSupport::Autoload + autoload :Base + autoload :Json + autoload :Xml end module Middleware - autoload :Base, 'grape/middleware/base' - autoload :Versioner, 'grape/middleware/versioner' - autoload :Formatter, 'grape/middleware/formatter' - autoload :Error, 'grape/middleware/error' + extend ActiveSupport::Autoload + autoload :Base + autoload :Versioner + autoload :Formatter + autoload :Error + autoload :Globals module Auth - autoload :Base, 'grape/middleware/auth/base' - autoload :DSL, 'grape/middleware/auth/dsl' - autoload :StrategyInfo, 'grape/middleware/auth/strategy_info' - autoload :Strategies, 'grape/middleware/auth/strategies' + extend ActiveSupport::Autoload + autoload :Base + autoload :DSL + autoload :StrategyInfo + autoload :Strategies end module Versioner - autoload :Path, 'grape/middleware/versioner/path' - autoload :Header, 'grape/middleware/versioner/header' - autoload :Param, 'grape/middleware/versioner/param' - autoload :AcceptVersionHeader, 'grape/middleware/versioner/accept_version_header' + extend ActiveSupport::Autoload + autoload :Path + autoload :Header + autoload :Param + autoload :AcceptVersionHeader end end module Util - autoload :InheritableValues, 'grape/util/inheritable_values' - autoload :StackableValues, 'grape/util/stackable_values' - autoload :InheritableSetting, 'grape/util/inheritable_setting' - autoload :StrictHashConfiguration, 'grape/util/strict_hash_configuration' + extend ActiveSupport::Autoload + autoload :InheritableValues + autoload :StackableValues + autoload :InheritableSetting + autoload :StrictHashConfiguration end module DSL - autoload :API, 'grape/dsl/api' - autoload :Callbacks, 'grape/dsl/callbacks' - autoload :Settings, 'grape/dsl/settings' - autoload :Configuration, 'grape/dsl/configuration' - autoload :InsideRoute, 'grape/dsl/inside_route' - autoload :Helpers, 'grape/dsl/helpers' - autoload :Middleware, 'grape/dsl/middleware' - autoload :Parameters, 'grape/dsl/parameters' - autoload :RequestResponse, 'grape/dsl/request_response' - autoload :Routing, 'grape/dsl/routing' - autoload :Validations, 'grape/dsl/validations' + extend ActiveSupport::Autoload + eager_autoload do + autoload :API + autoload :Callbacks + autoload :Settings + autoload :Configuration + autoload :InsideRoute + autoload :Helpers + autoload :Middleware + autoload :Parameters + autoload :RequestResponse + autoload :Routing + autoload :Validations + end end class API - autoload :Helpers, 'grape/api/helpers' + extend ActiveSupport::Autoload + autoload :Helpers + end + + module Presenters + extend ActiveSupport::Autoload + autoload :Presenter end end require 'grape/validations/validators/base' require 'grape/validations/attributes_iterator'