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