Sha256: dcf8c390c78965911dcfb64831fa5dac8a3433d24d3cea1df20123f15c2603b0

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true
# author: Vadim Shaveiko <@vshaveyko>
# :nodoc:
module RailsApiDoc
  module Controller
    module Response

      #
      # name - attribute key returned in json response
      # attr - actual attribute usage attribute
      # nested - attribute nesting if present
      # model - attribute model if nested and has model
      # desc - description for attribute
      # type - attribute type if set
      # id - param id in DB for lookup on display
      #
      class Param < RailsApiDoc::Controller::Param

        define_accessors *VALID_RESPONSE_KEYS

        def initialize(name, attr, nested, model = nil, desc = nil, type = nil, id = nil, action_type = nil, is_new: false)
          @name = name
          @store = {
            name: name,
            attr: attr,
            nested: nested,
            model: model,
            desc: desc,
            type: type,
            action_type: action_type,
            id: id
          }.compact

          @is_new = is_new
          @new = []
        end

        def nested?
          !nested.nil?
        end

        def display_value
          title = attr.to_s
          title += '(NESTED)' if nested?
          title
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_api_documentation-0.3.4 lib/rails_api_doc/controller/response/param.rb
rails_api_documentation-0.3.3 lib/rails_api_doc/controller/response/param.rb
rails_api_documentation-0.3.2 lib/rails_api_doc/controller/response/param.rb
rails_api_documentation-0.3.1 lib/rails_api_doc/controller/response/param.rb
rails_api_documentation-0.3.0 lib/rails_api_doc/controller/response/param.rb