Sha256: b33625f6f778a3da1c3ee9b5caa4ac6408f6134532e3e1784081c613bedb6afb

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 Bytes

Contents

require "active_support/concern"

module ApiRegulator
  module DSL
    extend ActiveSupport::Concern

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def api(controller_class, action, desc: nil, title: nil, &block)
        @api_definitions ||= []

        api_definition = Api.new(
          controller_class,
          action.to_s,
          desc: desc,
          title: title,
          &block
        )

        @api_definitions << api_definition
        ApiRegulator.api_definitions << api_definition
      end

      def webhook(event_name, desc: nil, title: nil, tags: [], &block)
        webhook = Webhook.new(event_name, desc: desc, title: title, tags: tags, &block)
        ApiRegulator.webhook_definitions << webhook
      end

      def api_definitions
        @api_definitions || []
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
api-regulator-0.1.11 lib/api_regulator/dsl.rb
api-regulator-0.1.10 lib/api_regulator/dsl.rb
api-regulator-0.1.9 lib/api_regulator/dsl.rb
api-regulator-0.1.8 lib/api_regulator/dsl.rb
api-regulator-0.1.7 lib/api_regulator/dsl.rb
api-regulator-0.1.6 lib/api_regulator/dsl.rb
api-regulator-0.1.5 lib/api_regulator/dsl.rb
api-regulator-0.1.4 lib/api_regulator/dsl.rb
api-regulator-0.1.3 lib/api_regulator/dsl.rb
api-regulator-0.1.2 lib/api_regulator/dsl.rb