Sha256: 88a93b8e04ce91da2ea3ae3f299e99932e86a23b15805307d08f3d06154dab4b

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

# frozen_string_literal: true
# author: Vadim Shaveiko <@vshaveyko>
# :nodoc:
class RailsApiDoc::Controller::Request::Repository

  extend RailsApiDoc::Controller::Request::Headers

  @repo = Hash.new { |hsh, key| hsh[key] = Hash.new { |hsh, key| hsh[key] = Param.new(key) } }

  class << self

    def method_missing(name, *args, &block)
      return @repo.send(name, *args, &block) if respond_to_missing?(name)
      super
    end

    def registered_controllers
      @repo.keys
    end

    def respond_to_missing?(method, *)
      @repo.respond_to?(method)
    end

    def []=(key, value)
      unless key < ActionController::Base
        raise ArgumentError, 'Repository keys are controllers only'
      end

      super
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_api_documentation-0.2.3 lib/rails_api_doc/controller/request/repository.rb