require "make_restful/version" module MakeRestful extend ActiveSupport::Concern extend ActiveSupport::Autoload autoload :ClassMethods autoload :Loaders autoload :RestMethods autoload :Rendering autoload :PermissibleSet autoload :PermissibleActions include RestMethods include Rendering delegate :allow_method?, :allow_format?, :resource_name, :instance_name, to: :klass included do class_attribute :json_root_node, :collection_loader, :instance_loader, instance_writer: false self.instance_loader = {} self.collection_loader = {} extend ClassMethods class_attribute :allowed_actions, :allowed_formats, :pagination_options, :resource_class, instance_writer: false attr_reader :resource, :instance, :collection self.pagination_options = {} self.allowed_actions = PermissibleActions.new(self) self.allowed_formats = PermissibleSet.new([:json, :jsonp, :xml]) private :klass, :allowed_actions, :allowed_formats, :pagination_options, :resource_class, :allow_method?, :allow_format?, :allowed_actions?, :allowed_formats?, :pagination_options?, :resource_class? helper_method :resource, :instance, :collection resource name.underscore.gsub(/(.*)_controller/,'\1').singularize rescue nil include Loaders end def klass self.class end end