lib/apipie/method_description.rb in apipie-rails-0.8.2 vs lib/apipie/method_description.rb in apipie-rails-0.9.0

- old
+ new

@@ -1,34 +1,16 @@ -require 'set' module Apipie class MethodDescription - - class Api - - attr_accessor :short_description, :path, :http_method, :from_routes, :options, :returns - - def initialize(method, path, desc, options) - @http_method = method.to_s - @path = path - @short_description = desc - @from_routes = options[:from_routes] - @options = options - end - - end - attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :headers, :show attr_accessor :metadata def initialize(method, resource, dsl_data) @method = method.to_s @resource = resource @from_concern = dsl_data[:from_concern] - @apis = api_data(dsl_data).map do |mthd, path, desc, opts| - MethodDescription::Api.new(mthd, concern_subst(path), concern_subst(desc), opts) - end + @apis = ApisService.new(resource, method, dsl_data).call desc = dsl_data[:description] || '' @full_description = Apipie.markup_to_html(desc) @errors = dsl_data[:errors].map do |args| @@ -201,27 +183,10 @@ @from_concern end private - def api_data(dsl_data) - ret = dsl_data[:api_args].dup - if dsl_data[:api_from_routes] - desc = dsl_data[:api_from_routes][:desc] - options = dsl_data[:api_from_routes][:options] - - api_from_routes = Apipie.routes_for_action(resource.controller, method, {:desc => desc, :options => options}).map do |route_info| - [route_info[:verb], - route_info[:path], - route_info[:desc], - (route_info[:options] || {}).merge(:from_routes => true)] - end - ret.concat(api_from_routes) - end - ret - end - def merge_params(params, new_params) new_param_names = Set.new(new_params.map(&:name)) params.delete_if { |p| new_param_names.include?(p.name) } params.concat(new_params) end @@ -257,18 +222,8 @@ example << "\n" << format_example_data(ex[:request_data]).to_s if ex[:request_data] example << "\n" << ex[:code].to_s example << "\n" << format_example_data(ex[:response_data]).to_s if ex[:response_data] example end - - def concern_subst(string) - return if string.nil? - if from_concern? - resource.controller._apipie_perform_concern_subst(string) - else - string - end - end - end end