Sha256: 7ef29648bd1f38b345655316c8ac86a6f8a9ac6a059c639d5756ec78cd28bb2d

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module Dox
  module DSL
    class Action
      include AttrProxy

      attr_writer :name
      attr_writer :verb
      attr_writer :path
      attr_writer :desc
      attr_writer :params
      attr_writer :query_params
      attr_writer :request_schema
      attr_writer :response_schema_success
      attr_writer :response_schema_fail

      def initialize(name, &block)
        self.name = name
        instance_eval(&block) if block_given?

        raise(Dox::Errors::InvalidActionError, 'Action name is required!') if @name.blank?
      end

      def config
        { action_request_schema: @request_schema.presence,
          action_response_schema_success: @response_schema_success.presence,
          action_response_schema_fail: @response_schema_fail.presence,
          action_name: @name.presence,
          action_verb: @verb.presence,
          action_path: @path.presence,
          action_desc: @desc.presence || '',
          action_params: @params,
          action_query_params: @query_params.presence || [] }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dox-2.5.0 lib/dox/dsl/action.rb
dox-2.4.0 lib/dox/dsl/action.rb
dox-2.3.0 lib/dox/dsl/action.rb
dox-2.2.0 lib/dox/dsl/action.rb
dox-2.1.0 lib/dox/dsl/action.rb
dox-2.0.0 lib/dox/dsl/action.rb
dox-2.0.0.beta3 lib/dox/dsl/action.rb
dox-2.0.0.beta2 lib/dox/dsl/action.rb
dox-2.0.0.beta1 lib/dox/dsl/action.rb