Sha256: b960370ba93e2de1a960498c42cd7b8d0f3650c1c782d68f55376ae5d9375eba

Contents?: true

Size: 874 Bytes

Versions: 21

Compression:

Stored size: 874 Bytes

Contents

module Apipie

  class ErrorDescription

    attr_reader :code, :description, :metadata

    def self.from_dsl_data(args)
      code_or_options, desc, options = args
      Apipie::ErrorDescription.new(code_or_options,
                                   desc,
                                   options)
    end

    def initialize(code_or_options, desc=nil, options={})
      if code_or_options.is_a? Hash
        code_or_options.symbolize_keys!
        @code = code_or_options[:code]
        @metadata = code_or_options[:meta]
        @description = code_or_options[:desc] || code_or_options[:description]
      else
        @code = code_or_options
        @metadata = options[:meta]
        @description = desc
      end
    end

    def to_json
      {
        :code => code,
        :description => description,
        :metadata => metadata
      }
    end

  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
apipie-rails-0.5.0 lib/apipie/error_description.rb
apipie-rails-0.4.0 lib/apipie/error_description.rb
apipie-rails-0.3.7 lib/apipie/error_description.rb
apipie-rails-0.3.6 lib/apipie/error_description.rb
apipie-rails-0.3.5 lib/apipie/error_description.rb
apipie-rails-0.3.4 lib/apipie/error_description.rb
apipie-rails-0.3.3 lib/apipie/error_description.rb
apipie-rails-0.3.2 lib/apipie/error_description.rb
apipie-rails-0.3.1 lib/apipie/error_description.rb
apipie-rails-0.3.0 lib/apipie/error_description.rb
apipie-rails-0.2.6 lib/apipie/error_description.rb
apipie-rails-0.2.5 lib/apipie/error_description.rb
apipie-rails-0.2.4 lib/apipie/error_description.rb
apipie-rails-0.2.3 lib/apipie/error_description.rb
apipie-rails-0.2.2 lib/apipie/error_description.rb
apipie-rails-0.2.1 lib/apipie/error_description.rb
apipie-rails-0.2.0 lib/apipie/error_description.rb
apipie-rails-0.1.3 lib/apipie/error_description.rb
apipie-rails-0.1.2 lib/apipie/error_description.rb
apipie-rails-0.1.1 lib/apipie/error_description.rb